1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24  // @Title: 第一个只出现一次的字符 (第一个只出现一次的字符 LCOF) // @Author: 15816537946@163.com // @Date: 2022-02-10 00:20:18 // @Runtime: 0 ms // @Memory: 2.2 MB impl Solution { pub fn first_uniq_char(s: String) -> char { let mut vec = vec![0; 26]; for c in s.chars() { let i = (c as u8 - 'a' as u8) as usize; vec[i] += 1; } for c in s.chars() { let i = (c as u8 - 'a' as u8) as usize; if vec[i] == 1 { return c; } } ' ' } }