-
-
Save jeremenichelli/8f238fdf7eae5d12c82e83e1d0ee0cbd to your computer and use it in GitHub Desktop.
#382
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Assumes gifts width are sorted in ascending order. | |
function wrapGifts(gifts, len) { | |
let i = 0 | |
let wrapped = 0 | |
let paperLength = len | |
while (paperLength > 0) { | |
paperLength = paperLength - gifts[i] | |
if (paperLength > -1) { ++wrapped } | |
++i | |
} | |
return wrapped | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment