i am unable to understand how the output is coming to be 2 while i am getting the output 4 even shifting the left edge by one.
please provide me the detailed explanation of input and output of this question
Unable to understand the output
Hello @D19APPPP0016,
In this question, you have to find the maximum area surrounded by the rivers.
There is no need to shift edges here.
You can implement the following approach:
- Make two vectors:
1.1. first: to store the x coordinates provided as input.
1.2. second: to store all the y coordinates provided as input. - Sort both the vectors.
- Find the maximum difference between the adjacent elements of each vector as dx and dy.
- 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.
Now, relate the testcase to above. and dry run them.
Hope, this would help.
Give a like, if you are satisfied.