Comments

Karan Kumar a year ago

const solve = (workers, tasks) => {
  return Math.ceil(tasks.reduce((x,y) => x+y)/workers)
};

Forges2 years ago

const solve = (workers, tasks) => {
  return Math.ceil(tasks.reduce((acc, cur) => acc + cur, 0) / 2);
};

Ergonomic compress2 years ago

Here is how I solved mine. Basically just resorting the workers array so that the most available worker always took the most work first.

const solve = (workers, tasks) => { let workerArray = new Array(workers).fill(0) let sortedTasks = tasks.sort((a,b) => a > b ? -1 : 1) while(sortedTasks.length){ workerArray[0] += sortedTasks.shift() workerArray = workerArray.sort((a,b) => a > b ? 1: -1) }

return Math.max(...workerArray) };