For example, given the data:
2 : 4
1 : 3
5 : 2
The function would return 2 since its value (4) is the highest.
I am doing:
let mut max_val = 0;
let mut max_key = "";
for (k, v) in a_hash_map.iter() {
if *v > max_val {
max_key = k;
max_val = *v;
}
}
Is there a nicer or quicker or simpler way to do this?