Skip to content

Commit

Permalink
Create first-non-repeating.py
Browse files Browse the repository at this point in the history
  • Loading branch information
gabedonnan authored Jan 27, 2023
1 parent 8e33363 commit 697f7d5
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions first-non-repeating.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Solution:
def firstUniqChar(self, s: str) -> int:
chars = {}
for j,char in enumerate(s):
if char in chars:
chars[char][0] = -1
else:
chars[char] = [1,j]

for ch in chars:
if chars[ch][0] == 1:
return chars[ch][1]
return -1

0 comments on commit 697f7d5

Please sign in to comment.