here we can only take the upper right corner at the initial starting index? to derive the 0(m+n) sol
Searching in the row-wise and the colwise sorted arrays
We choose the top right element as it is the most suitable for it. Because elements to left of it are smaller and the elements downwards are larger. So if target is less that top right element you move leftwards and it target is greater then you move downwards.
Similarly you can also choose bottom left as start point. Because on moving right from there, the value increases and decreases on moving upwards.
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.