❤leetcode,python2❤给定一个字符串,找到它的第一个不重复的字符,并返回它的索引。如果不存在,则返回 -1。

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_22795513/article/details/80655674
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

猜你喜欢

转载自blog.csdn.net/qq_22795513/article/details/80655674