Permuting Two Arrays

  • + 0 comments

    Short python solution :

    def twoArrays(k, A, B):
        s_A = sorted(A)
        r_B = sorted(B, reverse=True)
        for i in range(len(s_A)):  # since len(s_A) = len(A) = len(B)
            if s_A[i] + r_B[i] < k:
                return "NO"
        return "YES"