You are viewing a single comment's thread. Return to all comments →
Thanks. Here is the JS version of your code
function minTime(m, goal) { const min = Math.min(...m); const max = Math.max(...m); let minDay = Math.ceil(goal / m.length) * min; let maxDay = Math.ceil(goal / m.length) * max; const getSum = (arr, d) => arr.reduce((total, machine) => total + Math.floor(d / machine), 0); while (minDay < maxDay) { const day = Math.floor((maxDay + minDay) / 2); const sum = getSum(m, day); if (sum >= goal) { maxDay = day; } else { minDay = day + 1; } } return minDay; }
Minimum Time Required
You are viewing a single comment's thread. Return to all comments →
Thanks. Here is the JS version of your code