74. 搜索二维矩阵
https://leetcode-cn.com/problems/search-a-2d-matrix/
解法一:
通过坐标变换,将二维矩阵视为一维。由于是有序的,因此一维上依然是有序的。
n * m matrix convert to an array => matrix[x][y] => a[x * m + y]
an array convert to n * m matrix => a[x] =>matrix[x / m][x % m]
最后更新于
https://leetcode-cn.com/problems/search-a-2d-matrix/
通过坐标变换,将二维矩阵视为一维。由于是有序的,因此一维上依然是有序的。
n * m matrix convert to an array => matrix[x][y] => a[x * m + y]
an array convert to n * m matrix => a[x] =>matrix[x / m][x % m]
最后更新于