You are viewing a single comment's thread. Return to all comments →
My solution in rust:
n twoArrays(k: i32, A: &[i32], B: &[i32]) -> String { const YES: &str = "YES"; const NO: &str = "NO"; let mut sorted_a: Vec<i32> = A.to_vec(); let mut sorted_b: Vec<i32> = B.to_vec(); sorted_a.sort(); sorted_b.sort(); for (a_element, b_element) in sorted_a.iter().zip(sorted_b.iter().rev()) { if !(a_element + b_element >= k) { return NO.to_string(); } } YES.to_string() }
Seems like cookies are disabled on this browser, please enable them to open this website
Permuting Two Arrays
You are viewing a single comment's thread. Return to all comments →
My solution in rust: