ref:https://blog.csdn.net/u010089444/article/details/70854510


所以(python):
python展开代码class Solution:
    def findNumberIn2DArray(self, matrix: List[List[int]], target: int) -> bool:
        def find(x,y):
            if not (x<len(matrix) and y ):
                return False
            elif matrix[x][y-1]==target:
                return True
            elif matrix[x][y-1]>target:
                return find(x,y-1) # 目标值小,往左子树找
            else:
                return find(x+1,y) # 目标值大,往右子树找
        if len(matrix):
            return find(0,len(matrix[0]))
        else:
            return False


本文作者:Dong
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 CC BY-NC。本作品采用《知识共享署名-非商业性使用 4.0 国际许可协议》进行许可。您可以在非商业用途下自由转载和修改,但必须注明出处并提供原作者链接。 许可协议。转载请注明出处!