Created
June 11, 2020 23:42
-
-
Save waldrupm/f40450a5df54717de458648f8275d03d to your computer and use it in GitHub Desktop.
First non-repeating solution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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