class Solution {
public:
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param mat int整型vector<vector<>>
* @param n int整型
* @param m int整型
* @param x int整型
* @return int整型vector
*/
vector<int> findElement(vector<vector<int> >& mat, int n, int m, int x) {
// write code here
int row=0, col=m-1;
while ( row <=n-1 && col >=0) {
if(mat[row][col] == x) return {row,col};
if(mat[row][col] > x) --col;
else ++row;
}
return {-1,-1};
}
};

京公网安备 11010502036488号