The code is giving wrong output. For example if the target output is set to be zero the output is coming one. I have dry run the code but I think there is no problem. Link to code : https://ide.codingblocks.com/s/211521
Matrix Search Problem
Chirag, you are supposed to solve this question using staircase search as it is given that matrix is row-wise and column - wise sorted… So you can use the following approach as,
int i=0,j=m-1;
while(i<n && j>=0)
{
if(a[i][j]==val)
{
return true;
}
else
if(a[i][j]<val)
{
i++;
}
else
{
j–;
}
}