Search⌘ K
AI Features

Solution: First Unique Character in a String

Understand how to identify and return the first unique character's index in a string by applying hash map frequency tracking. This lesson teaches efficient traversal and frequency counting techniques for character sets limited to lowercase English letters, ensuring optimized time and constant space complexity.

Statement

For a given string of characters, s, your task is to find the first non-repeating character and return its index. Return 1-1 if there’s no unique character in the given string.

Constraints:

  • 11 \leq s.length ...