Skip to content

Instantly share code, notes, and snippets.

@waldrupm
Created June 11, 2020 23:42
Show Gist options
  • Select an option

  • Save waldrupm/f40450a5df54717de458648f8275d03d to your computer and use it in GitHub Desktop.

Select an option

Save waldrupm/f40450a5df54717de458648f8275d03d to your computer and use it in GitHub Desktop.
First non-repeating solution
def firstUniqChar(self, s):
wordlist = list(s)
# iterate over the string
for idx, letter in enumerate(wordlist):
current_letter = wordlist.pop(idx)
if current_letter in wordlist:
wordlist.insert(idx, current_letter)
else:
return idx
return -1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment