刷力扣热题–第二十七天:240.搜索二维矩阵(2)
 新手第二十七天 奋战敲代码,持之以恒,见证成长
1.题目简介

2.题目解答
这道题的想法就是,整体遍历,在遇到比target还大的,就停止这行的遍历,然后转过去继续遍历下一行,如果有一行的开头大于target,直接返回false.

 ok,过了,今天OVER!
3.心得体会
class Solution(object):
    def searchMatrix(self, matrix, target):
        """
        :type matrix: List[List[int]]
        :type target: int
        :rtype: bool
        """
        if matrix[0][0] > target or matrix[len(matrix)-1][len(matrix[0])-1] < target:
            return False
        for i in range(len(matrix)):
            for j in range(len(matrix[0])):
                if matrix[i][j] > target:
                    continue
                if i == 0 and matrix[i][j] > target:
                    return False
                if matrix[i][j] == target:
                    return True
        return False
 
4.做题时长
8月7日 15:50-16:00














![【AI学习】[2024北京智源大会]具身智能:具身智能关键技术研究:操纵、决策、导航](https://i-blog.csdnimg.cn/direct/c341daa544f64684a69f40ce58e9f8c0.png)




