标签:class ++ 搜索 二分 amp problems 双指针 public arch
problem:https://leetcode.com/problems/search-a-2d-matrix-ii
经典双指针二分查找题目。
class Solution { public: bool searchMatrix(vector<vector<int>>& matrix, int target) { int m = matrix.size(); if(!m) return false; int n = matrix[0].size(); if(!n) return false; int i = 0; int j = n - 1; while(i < m && j >= 0) { if(target == matrix[i][j]) return true; else if(target > matrix[i][j]) i++; else j--; } return false; } };
[二分搜索] leetcode 240 Search a 2D Matrix II
标签:class ++ 搜索 二分 amp problems 双指针 public arch
原文地址:https://www.cnblogs.com/fish1996/p/11335373.html