leetcode——387. 字符串中的第一个唯一字符

简单题

class Solution(object):
    def firstUniqChar(self, s):
        """
        :type s: str
        :rtype: int
        """
        k=[]
        i=0
        while i<len(s):
            if s[i] in k:
                i+=1
            elif s.count(s[i])==1:
                return i
            else:
                k.append(s[i])
                i+=1
        return -1
执行用时 :176 ms, 在所有 python 提交中击败了53.69%的用户
内存消耗 :12.2 MB, 在所有 python 提交中击败了24.70%的用户
 
 
——2019.10.25
posted @ 2019-10-25 11:50  欣姐姐  阅读(215)  评论(0编辑  收藏  举报