First Unique Character

Easy · Hashing · about 10 minutes

Asked at Amazon, Bloomberg, Microsoft.

Given a string s of lowercase letters, return the index of its first non-repeating character, or -1 if every character repeats.

Related guides