Grand temple (sorting and searching)

i just dont understand the test case given acc. to me ans should be 6 with 2,4 and 5,2 as diagonal element

Hey Rahul, you are supposed to find the max area, and for having an area you must have a rectangle for that you will need 4 points and for given test case we found that 2,2), (2,4), (5,2), (5,4) these are the 4 points which will give us the maximum area. There is one thing you need to keep in mind while calculating the area i.e. the area will be calculated from the edge next to the left edge, the edge above the bottom edge, the topmost edge and the rightmost edge, therefore for the region (2,2) , (2,4) , (5,2) , (5,4) the actual area will be considered from (3,2), (3,4), (5,2), (5,4) respectively.

Sir I said ans should be 6 but with points that u have given area should be 4 but still ans is 2
Please also tell why are we subtracting one from X co-ordinate also please tell how to find points i have given a thought about it but unable to figure out

Hey Rahul you can’t calculate are area of a rectangle using 2 diagonal coordinates are 2,4 and 5,2 the other two will be 2,2 and 5,4 and as i have said area will be calculated from the edge next to the left edge, the edge above the bottom edge therefore effectively area will be calculated for the rectangle formed by the coordinates (3,2), (3,4), (5,2), (5,4) which is 2.

Now why we are calculating area from the edge next to the left edge and the edge above the bottom edge. To understand this look at this figure given below

ignore those pillars and assume the dark rows and columns as rivers . So, in this picture you can see that if I am saying a river at (3,0) that means the width of the river is from 3,0 to 4,0 and in this way if you want to calculate the area to make temple you have to consider it from one next to the point where river is flowing.

How to get those points (2,2) (2,4) (5,2) (5,4). Is there any approch?
Please help

Area between (3,2) (3,4) (5,2) (5,4) is 4 units and there’s no arguement about it. You are explaining it wrong, and even in the explaination in the question, it is explained wrong there too. After the modifications to the diagram the actual area is from (3,3) (3,4) (5,3) (5,4) as the area is calculated from the edge above the bottom most edge, now the area comes out to be “2”. Am I wrong in explaining this?