function findMissing(numbers) {
const seen = new Set(numbers);
const n = Math.max(...numbers) + 1;
for (let i = 1; i <= n; i++) {
if (!seen.has(i)) {
return i;
}
}
return n + 1;
}
fn find_missing_number(v: &Vec<i32>) -> i32 {
let n = v.len() as i32 + 1;
let total = n * (n + 1) / 2;
let sum: i32 = v.iter().sum();
total - sum
}
fn main() {
let v = vec![1, 2, 4, 6, 3, 7, 8];
assert_eq!(find_missing_number(&v), 5); // no output
}