You are viewing a single comment's thread. Return to all comments →
using javascript
function equalStacks(h1, h2, h3) { let size1 = 0, size2 = 0, size3 = 0, maxSize = 0; while (true) { if (size1 === size2 && size2 === size3) maxSize = size1; if (!h1.length && !h2.length && !h3.length) { break; } if (size1 <= size2 && size1 <= size3 && h1.length) { size1 += h1.pop(); } else if (size2 <= size1 && size2 <= size3 && h2.length) { size2 += h2.pop(); } else if (size3 <= size1 && size3 <= size2 && h3.length) { size3 += h3.pop(); }else break } return maxSize; }
Seems like cookies are disabled on this browser, please enable them to open this website
Equal Stacks
You are viewing a single comment's thread. Return to all comments →
using javascript