First Unique Character in a String
Easy
Topics
Given a string s, return the index of the first non-repeating character. If none exists, return -1.
Example 1
Input: s = "leetcode" Output: 0
Example 2
Input: s = "loveleetcode" Output: 2
Example 3
Input: s = "aabb" Output: -1
Constraints
- 1 <= s.length <= 10^5
- s consists of lowercase English letters.
Run ⌘' · Submit ⌘⏎