387. First Unique Character in a String
387. First Unique Character in a String
Description
Difficulty: Easy
Related Topics: Hash Table, String, Queue, Counting
Given a string s
, find the first non-repeating character in it and return its index. If it does not exist, return -1
.
Example 1:
1 | Input: s = "leetcode" |
Example 2:
1 | Input: s = "loveleetcode" |
Example 3:
1 | Input: s = "aabb" |
Constraints:
- 1 <= s.length <= 105
s
consists of only lowercase English letters.
Hints/Notes
- map
Solution
Language: C++
1 | class Solution { |