// 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) {

        // write your code in Java SE 8

        Arrays.sort(A);
        int result = 0;

        for (int i = 0; i < A.length; i+=2) {

        if (A[i] == A.length - 1 || A[i] != A[i+1] ) {
                result = A[i];
                break;
            }
        }

        return result;

    }

}

'알고리즘' 카테고리의 다른 글

[codility] lesson5 - PassingCars  (0) 2020.08.14
[codility] lesson4 - FrogRiverOne  (0) 2020.08.13
[codility] lesson3 - FrogJmp  (0) 2020.08.12
[codility] lesson2 - CyclicRotation  (0) 2020.08.12
[codility] Lesson1 - Binary Gap  (0) 2020.08.12

+ Recent posts