Leetcode 每日一题
题目链接: 387. 字符串中的第一个唯一字符
难度: 简单
解题思路: 遍历直接返回第一个唯一字符的位置,没有则返回-1。
题解:

class Solution:
    def firstUniqChar(self, s: str) -> int:
        count = collections.Counter(s)
        for i in range(len(s)):
            if count[s[i]] == 1:
                return i
        return -1