class Solution {
public:
bool searchMatrix(vector<vector<int>>& matrix, int target) {
for(int i = 0, j = matrix[0].size() - 1; i < matrix.size() && j >= 0;){
if(target == matrix[i][j]){
return true;
}
if(target < matrix[i][j]){
j--;
}else{
i++;
}
}
return false;
}
};
04-16
552
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-06
274
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-14
212
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交