Doubt on understanding the question

here the river are the black color squares? i am not able to understand the diagram of the question

You are provided with the coordinated through which 2 rivers flow- one horizontally and the other one is flowing vertically. You have to build a temple provided the condition that the temple must be enclosed with a river on all 4 sides. You are supposed to find the max possible area for the temple.
For every possible area you must have a rectangle which is enclosed by different rivers on each side.

Sample Input

3
1 1
2 4
5 2

We have 3 points through which rivers flow horizontally as well as vertically.
For the 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. We also need to assume that the width of the river is 1 unit.
So, while calculating the area we need to ignore the area covered by river 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 to be (3,2), (3,4), (5,2), (5,4) after removal of the area covered by the river. Thus, giving the maximum area as 2 units.

still not able to understand what to do in this question

Which part were you not able to understand?

you just pasted the explanation part from the question

So, what were you not able to understand in the problem?

I explained it to you what needs to be done.
If you have any specific doubt, I’ll resolve it.
OR
Do you want to know the hints to the solution of the problem?

no no i don’t want the solution i just want to understand the question,but waht you explained earlier i was not able to understand it,please explain it properly

Which part of the question were you not able to understand? Please explain your doubt

whole question i didn’t understand

This question belongs to the Greedy Algorithm Section. Please complete the course content before proceeding to this question. You can then refer to the explanation mentioned above.

then why this question i given in this section

According to the Question , you are basically given n*n matrix and some coordinates, whose entire horizontal row line as well as vertically column line should be considered as river line. You need to find the maximum area of land which is enclosed by rivers on all 4 sides.

You can implement the following approach:

  1. Make two arraylists:
    1.1. first: to store the x coordinates provided as input.
    1.2. second: to store all the y coordinates provided as input.
  2. Sort both the lists.
  3. Find the maximum difference between the adjacent elements of each vector as dx and dy.
  4. Print the Area by multiplying both the differences.

Note:
Observe the figure carefully, you have to subtract 1 from both dx and dy before multiplication.

Hope, this would help.

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.