Algorithm/Problem Solving

[Java] Codility - PermMissingElem 문제 풀이

JeongKyun 2022. 9. 5.

문제

문제 바로가기

 


 

Task Score

100%

 

Correctness

100%

 

Performance

100%

 


 

문제 풀이

// you can also use imports, for example:
import java.util.*;

// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");

class Solution {
    public int solution(int[] A) {
        Arrays.sort(A);

        for (int i = 0; i < A.length; i++) {
            if(i+1 != A[i]){
                return i+1;
            }
        }
        return A.length + 1;    
    }
}
반응형

댓글

💲 많이 본 글