Matrix Search of an element in row and column wise sorted array

Given an n x m matrix, where every row and column is sorted in increasing order, and a number x . Find if element x is present in the matrix or not.

Input Format
First line consists of two space separated integers N and M, denoting the number of element in a row and column respectively. Second line of each test case consists of N*M space separated integers denoting the elements in the matrix in row major order. Third line of each test case contains a single integer x, the element to be searched.

solution link:https://ide.codingblocks.com/s/260239

one test case is not passing maybe due to constraint that value of elements should be less than 100. How to resolve this?

hello @1799sanya

image
these are the mistakes

actually it should be ->
image

@1799sanya Is your doubt resolved?

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.