Getting wrong answer

Bro, there is some logic problem

This is simple greedy approach
Basically u find sort the array because there will be horizontal and vertical rivers flowing all throught so no matter what the order of cordinates the area for building the temple is not hampered.

So after sorting we subtract consecutive array element and find max difference along x and y
also because the river occupies the entire block 1unit
we get the answer = (x_max- 1 )* (y_max-1);

But i am getting correct answer for above case and self made example

I tried it against the case
3 8
11 2
8 6

your code gave 35 as o/p
Correct answer is 12

my code is also giving 12 as output

please reply i am getting right answer

I am unable to figure out what is happening in your code
in the following line

 for(int i=0;i<n;i++){
        if(leftedge<=x[i]<=rightedge){
            if((x[i]-leftedge)<(rightedge-x[i]))
            leftedge=x[i];
            else
            rightedge=x[i];
        }
        if(bottomedge<=y[i]<=upperedge){
            if((y[i]-bottomedge)<(upperedge-y[i]))
            bottomedge=y[i];
            else upperedge=y[i];
        }
    }

If u could tell me, i might be able to sort out what is the problem with the code

ALso when i am running on large inputs the code is not responding

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.