You are viewing a single comment's thread. Return to all comments →
Good idea, i did something similar in JavaScript.
function getMoneySpent (s, n, m, kboards, drives) { let kasc = kboards.sort((a,b) => a - b), ddesc = drives.sort((a,b) => b - a), max = -1, sum, i = 0, j = 0; do { if ((sum = kasc[i] + ddesc[j]) == s) return sum; if (sum < s) { if (sum > max) max = sum; i++; } else { j++; } } while (i < n && j < m); 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 →
Good idea, i did something similar in JavaScript.