• + 0 comments

    Very simple python solution here

    def getMoneySpent(keyboards, drives, b):
        sortedKeyBoards = sorted(keyboards, reverse=True)
        drives = sorted(drives, reverse=True)
        sumMax = 0
        
        for i in range(len(sortedKeyBoards)):
            for j in range(len(drives)):
                sumTemp = sortedKeyBoards[i] + drives[j]
                if ( sumTemp >= sumMax and sumTemp <= b):
                    sumMax = sumTemp
                    
        return -1 if sumMax == 0 else sumMax