본문 바로가기

IT/알고리즘

[코딜리티] - Lesson 3. PermMissingElem

안녕하세요 남갯입니다.





public class PermMissingElem {

public static int solution(int[] A) {
// write your code in Java SE 8
int total = 0;
int result = 0;
for (int i = 0; i < A.length; i++) {
total += (i + 1);
result += A[i];
}
total += A.length + 1;
return total - result;
}
}