Simple python solution


  • 0
    L
    from collections import Counter
    class Solution(object):
        def firstUniqChar(self, s):
            """
            :type s: str
            :rtype: int
            """
            d=Counter(s)
            for i,c in enumerate(s):
                if d[c]==1:
                    return i
            return -1

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.