• + 0 comments

    java 8 Collections.sort(ar); int count = 0; int temp = 0; for(int i = 0; i < n; i++){

            if(temp == ar.get(i)){
                temp = 0;
                continue;
            }
            temp = ar.get(i);
            if((i + 1) < n && temp == ar.get(i + 1)){
                count++;
            }
        }
        return count;