Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ratulbasak/49a1ac51d7fd32df0be351e0adb7bbc1 to your computer and use it in GitHub Desktop.
Save ratulbasak/49a1ac51d7fd32df0be351e0adb7bbc1 to your computer and use it in GitHub Desktop.
ProblemSolving
class Solution:
def firstUniqChar(self, s: str) -> int:
sdict = {}
count = 0
arr = []
for i in s:
arr.append(i)
if i in sdict:
sdict[i] = sdict[i] + 1
else:
sdict[i] = 1
print(sdict, arr)
for i in range(len(arr)):
count += 1
if sdict[arr[i]] == 1:
return count - 1
return -1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment