Skip to content

Instantly share code, notes, and snippets.

@McLarenCollege
McLarenCollege / boxesInRowsWithoutMax.js
Last active May 12, 2021
Boxes in Rows without calculating max
View boxesInRowsWithoutMax.js
function boxesRows(boxes) {
let result = [];
while (1) {
let count = 0;
let zeroBoxCount = 0;
for (let i = 0; i < boxes.length; i++) {
if (boxes[i] > 0) {
boxes[i]--;
count++;
} else {