leetcode——240.搜索二维矩阵

class Solution:
    def searchMatrix(self, matrix, target):
        """
        :type matrix: List[List[int]]
        :type target: int
        :rtype: bool
        """
        #print(len(matrix))#行数
        #print(matrix[0])
        #print(len(matrix[0]))#列数
        
        for i in range(len(matrix)):
            #print(matrix[i])
            if target in matrix[i]:
                return True
            else:
                i+=1
        else:
            return False
执行用时 :48 ms, 在所有 Python3 提交中击败了96.07%的用户
内存消耗 :18.4 MB, 在所有 Python3 提交中击败了5.18%的用户
 
                                                                            ——2019.9.29
 
 
posted @ 2019-09-29 14:32  欣姐姐  阅读(151)  评论(0编辑  收藏  举报