Test Case 2 not passing Matrix Search

I have tried to implement binary search in Matrix search but it is not passing 2nd test case please Help and tell me if am doing something wrong

Code : https://ide.codingblocks.com/s/592117

Hey @rajputsiddharth18, the logic that you used is incorrect and it will fail for cases like:

1 5
2 6

You need to consider that each row and column is sorted individually but the matrix isn’t sorted as a whole. For this you need to apply binary search on each of the rows.

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.