Permuting Two Arrays

  • + 0 comments
    def twoArrays(k, A, B):
        diffs = sorted([(k - n) for n in B if n < k], reverse=True)
        sorted_A = sorted(A, reverse=True)
        
        return "YES" if all(x <= y for x, y in zip(diffs, sorted_A)) else "NO"