Created
October 29, 2019 15:08
-
-
Save daubattu/7af670d58a6b2e00ca96a3762889820c to your computer and use it in GitHub Desktop.
[Hackerrank] Solution of Electronics Shop in JavaScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getMoneySpent(keyboards, drives, b) { | |
/* | |
* Write your code here. | |
*/ | |
let max = -1; | |
for(let i = 0; i < keyboards.length; i++) { | |
const keyboardPrice = keyboards[i]; | |
for(let j = 0; j < drives.length; j++) { | |
const drivePrice = drives[j]; | |
if (keyboardPrice + drivePrice <= b && keyboardPrice + drivePrice > max) { | |
max = keyboardPrice + drivePrice; | |
} | |
} | |
} | |
return max; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment