Matrix search let me know the mistake

#include
using namespace std;

int staircasesearch(int arr[][1000],int m,int n,int key)
{
int i=0, j=n-1;

while(i<m && j>=0)
{
	if(arr[i][j]==key)
	{
		return 1;
	}

	else
	return 0;

}
cout<<0;

}

int main() {

int m,n;
cin>>m>>n;

int arr[m][1000];

for(int i=0;i<m;i++)
{
	for(int j=0;j<n;j++)
	{
		cin>>arr[i][j];
	}
}
int key;
cin>>key;

cout<<staircasesearch(arr,m,n,key);

return 0;

}

You are just checking the last element of first row, you are not updating i and j.

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.