런타임 스페이스 다 효율적으로 사용하래서 둘다 O(n)으로 했는데...
더 효율적으로 할 수 있는지... ;ㅅ;


       /*

         * It is known that the input vector a contains
         * only numbers between 1 and a.length-1 (both ends inclusive).
         * Find a number that occurs at least twice.
         * Examples:
         * A=[1,1,2,3] gives 1
         * A=[2,2,3,4,3] gives 2 or 3, either one is acceptable
         * A=[3,3,3,1] gives 3
         * A=[0,1,2,3] will not occur
         * The function is not allowed to modify A.
         */
        public int findTwins(int[] a) {
                int arr[] = new int[a.length]; // 복제배열 생성
                for(int i = 0; i < a.length; i++)
                {
                        arr[a[i]]++; // 복제 배열의 해당 원소 카운트
                }
                for(int j = 0; j < arr.length; j++)
                {
                        if(arr[j] >= 2) // 카운트해서 2 이상인거 출력
                                return j;
                }
                return 0;
                ///////////////////////////////////////////////////////////////
                // run-time : O(n)
                // space : O(n)
                ///////////////////////////////////////////////////////////////
        }