Created
December 11, 2017 18:56
-
-
Save proustibat/3f622e5d5a907e47c02727c872bfad81 to your computer and use it in GitHub Desktop.
Ratiorg got statues of different sizes as a present from CodeMaster for his birthday, each statue having an non-negative integer size. Since he likes to make things perfect, he wants to arrange them from smallest to largest so that each statue will be bigger than the previous one exactly by 1. He may need some additional statues to be able to ac…
This file contains hidden or 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
const makeArrayConsecutive2 = statues => Math.max( ...statues ) - Math.min( ...statues ) + 1 - statues.length; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example
For
statues = [6, 2, 3, 8]
, the output should bemakeArrayConsecutive2(statues) = 3
.Ratiorg needs statues of sizes 4, 5 and 7.