12 lines
249 B
Python
12 lines
249 B
Python
|
|
s = "eleetcode"
|
||
|
|
|
||
|
|
def firstUniqChar(s):
|
||
|
|
visited = set()
|
||
|
|
for i in range(len(s)):
|
||
|
|
if s[i] not in visited:
|
||
|
|
visited.add(s[i])
|
||
|
|
if s.count(s[i]) == 1:
|
||
|
|
return i
|
||
|
|
return -1
|
||
|
|
|
||
|
|
print( firstUniqChar(s) )
|