parent
5142f14aa0
commit
a7da4d8202
@ -0,0 +1,15 @@
|
|||||||
|
class Solution:
|
||||||
|
def firstUniqChar(self, s: str) -> int:
|
||||||
|
if len(s)==0:
|
||||||
|
return -1
|
||||||
|
res = {}
|
||||||
|
for each in s:
|
||||||
|
if each in res:
|
||||||
|
res[each]+=1
|
||||||
|
else:
|
||||||
|
res[each] = 1
|
||||||
|
for i,each in enumerate(s):
|
||||||
|
if res[each] ==1:
|
||||||
|
return i
|
||||||
|
return -1
|
||||||
|
|
Loading…
Reference in new issue