class Solution {
public:
vector<int> findElement(vector<vector<int> > mat, int n, int m, int x) {
// write code here
vector<int> A;
if(mat.size()<=0||mat[0].size()<=0)
return A;
int i=n-1,j=0;//从左下角开始查找x
while(i>=0&&j<m){
if(mat[i][j]==x){
A.push_back(i);
A.push_back(j);
return A;
}
else if(x>mat[i][j]){
j++;
}
else i--;
}
return A;
}
};
public:
vector<int> findElement(vector<vector<int> > mat, int n, int m, int x) {
// write code here
vector<int> A;
if(mat.size()<=0||mat[0].size()<=0)
return A;
int i=n-1,j=0;//从左下角开始查找x
while(i>=0&&j<m){
if(mat[i][j]==x){
A.push_back(i);
A.push_back(j);
return A;
}
else if(x>mat[i][j]){
j++;
}
else i--;
}
return A;
}
};