Technical Interview Question: First Unique Character in a String [LeetCode]

preview_player
Показать описание
Check out my interview prep platform for learning the patterns!

Рекомендации по теме
Комментарии
Автор

Great explanations - I subscribed. If you're still doing these, I'd love to see videos on graph problems using BFS, DFS, etc.

leob.
Автор

Inside for loop (C#): if (s.IndexOf(s[i]) == s.LastIndexOf(s[i])) return i; it works, not sure about complexity, but looks the same :)

emaxn
Автор

dude i wish i could give your video more likes

jeffge
Автор

Do you always recommend using c# or java for string problems?

milaness
Автор

Can you make video of Trapping Rain Water Problem?

ashiqimran
Автор

Are you sure the Map class guaranteed order?

imadalamaddin
Автор

public int firstUniqChar(String s) {
char[] charArray = new char[26];
for(int i = 0 ; i<s.length();i++){
charArray[s.charAt(i) - 'a'] += 1;

}
for(int i = 0 ; i<s.length();i++){
if(charArray[s.charAt(i)-'a'] == 1) return i;
}

return -1;
}
better :)

leyocode
visit shbcf.ru