第96天。
今天的题目是Search a 2D Matrix II:
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 in ascending from left to right. Integers in each column are sorted in ascending from top to bottom. For example,
Consider the following matrix:
Given target = 5, return true.
Given target = 20, return false.
以前好像看过这道题,但是应该嫌麻烦没做,今天做了一下,感觉好像也不是很难的样子,二分查找的升级版(在2维情况下):
为什么dicuss
的解法大多都是: