LeetCode 74. Search a 2D Matrix

Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:

Integers in each row are sorted from left to right.
The first integer of each row is greater than the last integer of the previous row.
For example,

Consider the following matrix:

[
[1, 3, 5, 7],
[10, 11, 16, 20],
[23, 30, 34, 50]
]
Given target = 3, return true.

题目大意:编写一个有效的算法,在m×n矩阵中搜索一个值。 该矩阵具有以下属性:
每行中的整数从左到右排序。每行的第一个整数大于前一行的最后一个整数。

分析:对每一行进行二分搜索,如果找到了就返回true否则返回false~

❤❤点击这里 -> 订阅PAT、蓝桥杯、GPLT天梯赛、LeetCode题解离线版❤❤