You are viewing a single comment's thread. Return to all comments →
RUST:
fn pickingNumbers(a: &[i32]) -> i32 { let mut a_sorted: Vec<i32> = a.to_vec(); a_sorted.sort_unstable(); let mut max_counter = 0; let mut counter = 0; let mut checked = a_sorted[0]; for num in a_sorted { if (checked - num).abs() > 1 { checked = num; counter = 1; } else { counter += 1; } max_counter = max_counter.max(counter); } max_counter }
Seems like cookies are disabled on this browser, please enable them to open this website
Picking Numbers
You are viewing a single comment's thread. Return to all comments →
RUST: