You are viewing a single comment's thread. Return to all 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
Seems like cookies are disabled on this browser, please enable them to open this website
Electronics Shop
You are viewing a single comment's thread. Return to all comments →
Very simple python solution here