Find Lucky Integer in an Array LeetCode solution in Rust

1
use std::collections::HashMap;
2
impl Solution {
3
pub fn find_lucky(arr: Vec<i32>) -> i32 {
4
let mut hm = HashMap::new();
5

6
for i in arr {
7
*hm.entry(i).or_insert(0) += 1;
8
}
9
let mut max = -1;
10
for (key, value) in hm {
11
if key == value && key > max {
12
max = key;
13
}
14
}
15
max
16
}
17
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0