:type s: str :rtype: int
(self, s)
| 25 | """ |
| 26 | class Solution(object): |
| 27 | def firstUniqChar(self, s): |
| 28 | """ |
| 29 | :type s: str |
| 30 | :rtype: int |
| 31 | """ |
| 32 | |
| 33 | x = {} |
| 34 | |
| 35 | for i in s: |
| 36 | try: |
| 37 | x[i] += 1 |
| 38 | except: |
| 39 | x[i] = 1 |
| 40 | |
| 41 | for i in x.keys(): |
| 42 | if x[i] > 1: |
| 43 | x.pop(i) |
| 44 | |
| 45 | for i in range(len(s)): |
| 46 | if s[i] in x: |
| 47 | return i |
| 48 | return -1 |