function solution(A) {
let n = A.length + 1;
let sumAll = n * (n + 1) / 2; // sum(1..N)
let sumArray = A.reduce((prev, curr) => prev + curr, 0);

return sumAll - sumArray;
}


'IT General' 카테고리의 다른 글

Codility #7-Brackets  (0) 2018.08.18
Codility #7-Nesting  (0) 2018.08.18
Codility #3-FrogJmp  (0) 2018.08.18
Codility #2-OddOccurrencesInArray  (0) 2018.08.18
Codility #2-CyclicRotation  (0) 2018.08.18

+ Recent posts