728x90
SMALL
안녕하세요 남갯입니다.
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;
}
}
728x90
LIST
'IT > 알고리즘' 카테고리의 다른 글
[코딜리티] - Lesson 4. FrogRiverOne (0) | 2019.08.12 |
---|---|
[코딜리티] - Lesson 3. TapeEquilibrium (0) | 2019.08.05 |
[코딜리티] - Lesson 3. FrogJmp (0) | 2019.08.05 |
[코딜리티] - Lesson 2. CyclicRotation (0) | 2019.07.29 |
[코딜리티] - Lesson 2. OddOccurrencesInArray - 1 (0) | 2019.07.29 |