You are viewing a single comment's thread. Return to all comments →
//my js solution function getMoneySpent(keyboards, drives, b) { let sum = 0; let budget = [] for (let i = 0; i < keyboards.length; i++) { for (let j = 0; j < drives.length; j++) { sum = keyboards[i] + drives[j] if (sum <= b) { budget.push(sum) } } } let result = Math.max(...budget) if (budget.length === 0) { return -1 } else { return result } }
Electronics Shop
You are viewing a single comment's thread. Return to all comments →