class Solution(object):
def firstUniqChar(self, s):
"""
:type s: str
:rtype: int
"""
for i in range(len(s)):
if s[i] not in s[i+1:] and s[i] not in s[:i]:
return i
return -1
❤leetcode,python2❤给定一个字符串,找到它的第一个不重复的字符,并返回它的索引。如果不存在,则返回 -1。
最新推荐文章于 2023-06-15 17:41:17 发布