Codility #9. PermCheck
너무 쉬웠던 문제
시간복잡도는  N 이 나올테지만, 최대한 줄여볼려고 2/N까지는 만들었다. 그리고 조합의 예외 케이스 잡아주는 로직 하나 넣어주면 끝 
// 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");
import java.util.*;
class Solution {
    public int solution(int[] A) {
        // write your code in Java SE 8
        int N = A.length;
        Arrays.sort(A);
        
        int sum = A[0] + A[N-1];
        if(A[0] != 1 || A[N-1] != N) {
            return 0;
        }
        
        for(int i = 0; i < N/2; i++) {
            if(A[i] + A[N-1-i] != sum ) {
                return 0;
                
            }
        }
        return 1;
    }
}
Author And Source
이 문제에 관하여(Codility #9. PermCheck), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@keithcha/Codility-9.-PermCheck저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)