Your question is First Non-Repeating Character Index. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Spotify wants a small utility to quickly analyze short text tokens. Write a Python function that returns the index of the first character in a string that appears exactly once.
Implement a function first_unique_char(s) where:
s containing lowercase English letters-1 if every character appears more than onceA clean solution should avoid comparing every character with every other character. Aim for a linear-time approach using a frequency count, then scan the string again to find the first index whose count is 1.
def first_unique_char(s):