Staircase search

can i get the code for this algorithm please

@Siddhantm Refer the lecture video and try it yourself.It is easy.
Refer this for help

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.

#include<bits/stdc++.h>
using namespace std;

void array_search(int arr[][50],int key,int m,int n)
{

int count=0;

int rows=0;

int col=n-1;

while(col>=0)
{
	if(key>arr[rows][col]){
		rows++;
	}
	   
	else if(key<arr[rows][col]){
		col--;
}

else{
	cout<<arr[rows][col];
	count++;
	break;
	
}

}

if(count!=0){
cout<<“key found:-”<<endl;

}
else{
cout<<“Key not found:-”<<endl;
cout<<"-1"<<endl;
}

}

int main()
{

int m,n,key;

cout<<"Enter m && n:-"<<endl;

cin>>m>>n;

cout<<"Enter Key Element:-"<<endl;
	
 cin>>key;
	


int a[50][50];

cout<<"Enter 2-D array elements:-"<<endl;

for(int rows=0;rows<m;rows++){
	
	
	for(int col=0;col<n;col++){
		
		cin>>a[rows][col];
	}
	
}
	
	
	array_search(a,key,m,n);
	
	
	
	return 0;
	
}