fork download
  1. # your code goes here
  2. class Solution(object):
  3. def firstUniqChar(self, s):
  4. """
  5. :type s: str
  6. :rtype: int
  7. """
  8. x = {}
  9. for i in s:
  10. x[i] = x.get(i,0)+1
  11.  
  12. for i in range(len(s)):
  13. if x[s[i]] == 1:
  14. return i
  15.  
  16. return -1
  17.  
Success #stdin #stdout 0.07s 13996KB
stdin
Standard input is empty
stdout
Standard output is empty