Skip to content

Latest commit

 

History

History
executable file
·
9 lines (5 loc) · 464 Bytes

387.md

File metadata and controls

executable file
·
9 lines (5 loc) · 464 Bytes

387. First Unique Character in a String

Given a string s, return the first non-repeating character in it and return its index. If it does not exist, return -1.

Too many methods to solve this question.

we can iterate each words in string's order. We can build a unordered_set. If this char is in the set, we skip current character. For each character, we iterate its successor and find the duplicates. If there is no duplicate, return current character.

AC!