MCPcopy Create free account
hub / github.com/StudyRust/leetcode_rust / single_number

Method single_number

260-single-number-iii.rs:4–13  ·  view source on GitHub ↗
(nums: Vec<i32>)

Source from the content-addressed store, hash-verified

2
3impl Solution {
4 pub fn single_number(nums: Vec<i32>) -> Vec<i32> {
5 use std::collections::HashMap;
6 let mut mmp = HashMap::new();
7 for num in nums {
8 let count = mmp.entry(num).or_insert(0);
9 *count += 1;
10 }
11 mmp.retain(|_, v|*v==1);
12 mmp.into_keys().collect::<Vec<i32>>()
13 }
14}
15
16fn main() {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected