PTMSSNG - Editorial

great,
thanks

thanks man saved my time

Can someone please explain why my code is not working? TIA!

#include <iostream>
using namespace std;

int partition(int arr[], int s, int e){
    int pIndex = s;
    int pivot = arr[e];
    for(int i=s; i<=e; i++){
        if (arr[i]<=pivot){
            int temp = arr[i];
            arr[i] = arr[pIndex];
            arr[pIndex] = temp;
            pIndex++;
        }
    }
    return pIndex-1;
}

void quickSort(int arr[], int s, int e){
    if(s<e){
        int pIndex = partition(arr, s, e);
        quickSort(arr, s, pIndex-1);
        quickSort(arr, pIndex+1, e);
    }
}

int main() {
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        int x[(4*n) - 1];
        int y[(4*n) - 1];
        for(int i=0; i<(4*n-1); i++){
            cin>>x[i]>>y[i];
        }
        
        quickSort(x, 0, 4*n-2);
        quickSort(y, 0, 4*n-2);
        
        int xValue;
        int xCount=1;
        
        for(int i=1; i<((4*n) - 1); i++){
            if(x[i]==x[i-1]) xCount++;
            else{
                if(xCount%2 == 0){
                    xCount=1;
                }
                else{
                    xValue = x[i-1];
                    break;
                }
            }
            
        }
        
        int yValue;
        int yCount=1;
        
        for(int i=1; i<((4*n) - 1); i++){
            if(y[i]==y[i-1]) yCount++;
            else{
                if(yCount%2 == 0){
                    yCount=1;
                }
                else{
                    yValue = y[i-1];
                    break;
                }
            }
            
        }
        cout<<xValue<<" "<<yValue<<endl;
    }
	return 0;
}

Java. Can some one please help me find the error in my code. It is failing for subtask 2

  /* package codechef; // don't place package name! */

 import java.util.*;
 import java.lang.*;
 import java.io.*;
  import java.util.Map.Entry;
  /* Name of the class has to be "Main" only if the class is public. */
 class Codechef
 {
public static void main (String[] args) throws java.lang.Exception
{
    BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
    int t= Integer.parseInt(br.readLine());
    int a=0;
    int b=0;
    while(t-->0){
       int N= Integer.parseInt(br.readLine());
       HashMap<Integer,Integer> mapa= new HashMap<Integer,Integer>();
       HashMap<Integer,Integer> mapb= new HashMap<Integer,Integer>();
       for(int i=0;i<4*N-1;i++){
           String[] input= br.readLine().split(" ");
            int x= Integer.parseInt(input[0]);
            int y= Integer.parseInt(input[1]);
            mapa.put(x,mapa.getOrDefault(x,0)+1);
            mapb.put(y,mapb.getOrDefault(y,0)+1);
           
       }
       for(Entry<Integer, Integer> entry: mapa.entrySet()) {
           if(entry.getValue() == 1) {a=entry.getKey();}}
           
        for(Entry<Integer, Integer> entry: mapb.entrySet()) {
           if(entry.getValue() == 1) {b=entry.getKey();}}   
        
       //System.out.println(Arrays.asList(mapa));
       //System.out.println(Arrays.asList(mapb));
       
        System.out.println(a+" "+b);
        }

}


}

I am probably late, but this should fix your issue.

Change it to

if(entry.getValue() % 2 == 1)