You are viewing a single comment's thread. Return to all comments →
Just with a double for-iteration in Java works already... Using sort functions makes internally more loop operations to reorder each array.
static int getMoneySpent(int[] keyboards, int[] drives, int budget) { int max = -1; for (int i = 0; i < keyboards.length; i++) { for (int j = 0; j < drives.length; j++) { if (keyboards[i] + drives[j] <= budget && keyboards[i] + drives[j] > max) max = keyboards[i] + drives[j]; } } return max; }
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 →
Just with a double for-iteration in Java works already... Using sort functions makes internally more loop operations to reorder each array.