Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::collections::HashMap;
- pub fn str_is_unique(s: &str) -> bool {
- let mut map: HashMap<char, i32> = HashMap::new();
- for c in s.chars() {
- *map.entry(c).or_insert(0) += 1;
- }
- !map.iter().any(|(_, &v)| v > 1)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement