Matrix search in hb

https://ide.codingblocks.com/#/s/30695
https://hack.codingblocks.com/contests/c/452/705
failing 2nd test case
please fix it

You can not apply binary search on the entire matrix considering it as a 1-D array as it is not entirely sorted.
It is row-wise and column-wise sorted.

For eg;
3 3
1 2 5
4 6 12
10 11 12

is a valid input, but if you consider 1D array corresponding to this, it is
1 2 5 4 6 12 10 11 12
which is not at all sorted.

Try searching 5 in your code for this matrix, answer will be NO, but it is present in the matrix…

HINT:
Try binary search on each row or each column.

I am still working on binary search.
can you provide the code for reference?

https://ide.codingblocks.com/#/s/31053

Here is my code for your reference.