10.21 First Non-Repeated Character
10.21.1 Problem Metadata
- Platform: Interview Prep
- Problem ID: First Unique Character
- Difficulty: Easy
- URL: N/A
- Tags:
- Techniques: Hash Table, String
10.21.2 Description
Given a string s, return the index of the first non-repeating character. If every character repeats, return -1.
10.21.5 Solution - Frequency Counting
10.21.5.1 Walkthrough
Count occurrences of every character using an array keyed by ASCII value. A second pass over the string returns the first index with frequency 1.