Rust Two Pointers with HashMap
I like the HashMap.insert function returning the old value :)\nrust\nuse std::collections::HashMap;\n\nimpl Solution {\n    pub fn length_of_longest_substring(s
I like the HashMap.insert function returning the old value :)\n```rust\nuse std::collections::HashMap;\n\nimpl Solution {\n    pub fn length_of_longest_substring(s: String) -> i32 {\n        let mut hash: HashMap<char, i32> = HashMap::new();\n        let mut ans = 0;\n        let mut lo = -1;\n        for (hi, ch) in s.chars().enumerate() {\n            if let Some(i) = hash.insert(ch, hi as i32) {\n                lo = lo.max(i);\n            }\n            ans = ans.max(hi as i32 - lo);\n        }\n        ans\n    }\n}\n```
['Two Pointers', 'Rust']