First Unique Character
Module 6 · Hash Tables
Problem
Given a string s, return the index of the first character that appears
exactly once, or −1 if none exists.
Examples
Example 1
Input
"leetcode"Output0Explanation. l
Example 2
Input
"loveleetcode"Output2Explanation. v
Example 3
Input
"aabb"Output-1Constraints
1 ≤ n ≤ 10⁵ · lowercase English letters.
Attempt it first
The patterns-lesson quiz literally contained this problem's shape. The one design decision worth pausing on: why must there be two passes, and over what?