leetcode之Search a 2D Matrix II

来源:互联网 发布:erp软件命令 编辑:程序博客网 时间:2024/05/19 00:38

这个题目II和I对于python来说,都是一样的,代码都不用换。代码如下:

class Solution(object):    def searchMatrix(self, matrix, target):        """        :type matrix: List[List[int]]        :type target: int        :rtype: bool        """        list1 = []        for i in matrix:            list1.extend(i)        if target in list1:            return True        else:            return False


0 0
原创粉丝点击