Permuting Two Arrays

  • + 0 comments

    Python:

    def twoArrays(k, A, B):
        if sum(A)+sum(B)<k*len(A):
            return "NO"
        
        sort_A=sorted(A)
        sort_B=sorted(B,reverse=True)
        
        for i in range(len(A)):
            if sort_A[i]+sort_B[i]<k:
                return 'NO'
                
        return 'YES'