Loading…
Loading…
Given a string, print the index of its first non-repeating character, or -1 if none exists.
Input: leetcode
Output: 0 (l never repeats and appears first)
Two passes with a hash map: first count every character's frequency, then scan again in order and return the first index whose count is 1.
Input (stdin)
Output
Input (stdin)
Output
Sign in to track solved problems and earn XP.