2019-11-10 LeetCode in Rust LeetCode 1056. Confusing Number Problem Statement Backtrack. use std::collections::HashMap;impl Solution { pub fn confusing_number(n: i32) -> bool { let s = n.to_string(); let map: HashMap<char, char> = [('1', '1'), ('6', '9'), ('8', '8'), ('9', '6'), ('0','0')] .iter().cloned().collect(); let (mut changed, mut i, mut j) = (false, 0, s.len() - 1); while i <= j { if !map.contains_key(&s.chars().nth(i).unwrap()) || !map.contains_key(&s.chars().nth(j).unwrap()) { return false; } if map[&s.chars().nth(i).unwrap()] != s.chars().nth(j).unwrap() { changed = true; } i += 1; if j != 0 { j -= 1; } } return changed; }} Newer LeetCode 1055. Shortest Way to Form String Older LeetCode 1059. All Paths from Source Lead to Destination