Problems / First Unique Character
Easy

First Unique Character

Easy 275 submissions 10 coins +50 XP
Hash Table String
Problem Description
Return the index of the first character in `s` that appears exactly once. If every character repeats, return `-1`. **Example 1:** ``` Input: s = "compilemate" Output: 0 ``` **Example 2:** ``` Input: s = "aabbc" Output: 4 ``` **Example 3:** ``` Input: s = "aabb" Output: -1 ```
Constraints
- `1 <= s.length <= 10^5` - Lowercase English letters only.

Need help?

Connect with expert programmers for real-time collaborative coding, video meetings, and whiteboard sessions via CodeConnect.

Video Call Whiteboard Live Coding Screen Share