Permuting Two Arrays

  • + 0 comments

    Rust solution:

    fn twoArrays(k: i32, A: &mut [i32], B: &mut [i32]) -> String {
        A.sort();
        B.sort();
        
        for (a, b) in A.iter().zip(B.iter().rev()) {
            if a + b < k {
                return "NO".to_string();
            }
        }
        
        "YES".to_string()
    }