【发布时间】:2011-03-29 11:49:22
【问题描述】:
可能的重复:
Given a 2d array sorted in increasing order from left to right and top to bottom, what is the best way to search for a target number?
Search a sorted 2D matrix
在二维矩阵中查找元素的高效程序,其行和列单调递增。 (行和列从上到下,从左到右递增)。
如果对二维数组进行排序,我只能想到二分查找。
【问题讨论】:
-
即使单调递增而不是排序,也可以进行一种二分搜索,但正如所指出的,还有更好的方法。
标签: algorithm