387. First Unique Character in a String Easy

@problem@discussion
#Hash Table#String#Queue#Counting



1/**
2 * [387] First Unique Character in a String
3 *
4 * Given a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1.
5 *  
6 * Example 1:
7 * Input: s = "leetcode"
8 * Output: 0
9 * Example 2:
10 * Input: s = "loveleetcode"
11 * Output: 2
12 * Example 3:
13 * Input: s = "aabb"
14 * Output: -1
15 *  
16 * Constraints:
17 * 
18 * 	1 <= s.length <= 10^5
19 * 	s consists of only lowercase English letters.
20 * 
21 */
22pub struct Solution {}
23
24// problem: https://leetcode.com/problems/first-unique-character-in-a-string/
25// discuss: https://leetcode.com/problems/first-unique-character-in-a-string/discuss/?currentPage=1&orderBy=most_votes&query=
26
27// submission codes start here
28
29impl Solution {
30    pub fn first_uniq_char(s: String) -> i32 {
31        0
32    }
33}
34
35// submission codes end
36
37#[cfg(test)]
38mod tests {
39    use super::*;
40
41    #[test]
42    fn test_387() {
43    }
44}
45


Back
© 2025 bowen.ge All Rights Reserved.