Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

make array consecutive javascript

function solution(statues) {
    var min = Math.min(...statues);
    var max = Math.max(...statues);
    var count = 0;
    for (var i = min; i <= max; i++) {
        if (!statues.includes(i)) {
            count++;
        }
    }
    return count;
}
 
PREVIOUS NEXT
Tagged: #array #consecutive #javascript
ADD COMMENT
Topic
Name
5+4 =