leetcode_gym/_code/strings/firstNonRepeating.py
2026-08-25 19:14:07 -06:00

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) )