IT General

Codility #3-PermMissingElem

SoftArts 2018. 8. 18. 20:11
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;
}