You are viewing a single comment's thread. Return to all comments →
function cutTheSticks(sticks) { let ans = []; let min = Math.min(...sticks); while(sticks.length) { ans.push(sticks.length); let newSticks = []; let newMin = 1001; for(let length of sticks) { let newLength = length - min; if(newLength > 0) { newSticks.push(newLength); newMin = Math.min(newMin, newLength); } } min = newMin; sticks = [...newSticks]; } return ans; }
Seems like cookies are disabled on this browser, please enable them to open this website
Cut the sticks
You are viewing a single comment's thread. Return to all comments →