You are viewing a single comment's thread. Return to all comments →
JS binary search
function minTime(machines, goal) { let min = 1, max = goal * Math.max(...machines) while (min < max) { let mid = parseInt((min + max) / 2) let prod = machines.reduce((prev, curr) => prev + parseInt(mid / curr), 0) if (prod < goal) min = mid + 1 else max = mid } return min }
Seems like cookies are disabled on this browser, please enable them to open this website
Minimum Time Required
You are viewing a single comment's thread. Return to all comments →
JS binary search