We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
function stoneDivision(n, s) {
const m = {};
function stoneD(pile) {
if(pile in m) return m[pile];
let max = 0;
for(let i of s) {
if(pile % i === 0 && i !== pile) {
max = Math.max(max, 1 + (pile / i) * stoneD(i));
}
}
m[pile] = max;
return max;
}
return stoneD(n);
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Stone Division, Revisited
You are viewing a single comment's thread. Return to all comments →
Answer in JavaScript: