Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. def first_uniq_char(s):
  2. idx_list = []
  3. char_set = set()
  4. char_dup_set = set()
  5. for char in s:
  6. if char in char_set:
  7. char_set.remove(char)
  8. char_dup_set.add(char)
  9. elif char not in char_dup_set:
  10. char_set.add(char)
  11.  
  12. for i in range(len(s)):
  13. if s[i] in char_set:
  14. return i
  15. return
  16.  
  17. # print(first_uniq_char("leetcode"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement