Rust Perm Missing Element
fn perm_missing_element(mut a: Vec<i64>) -> i64 {
a.sort();
for (k, &v) in a.iter().enumerate() {
if v != k as i64 + 1 {
return k as i64 + 1;
}
}
a.len() as i64 + 1
}
This uses the expected sum of 1..N+1 and subtracts the actual sum to find the missing value.