您的位置:首页 > 编程语言 > Python开发

leetcode之Search a 2D Matrix

2015-10-21 00:15 507 查看
这个题目是来寻找list[list]里是否含有指定的数。对于python来讲就太简单了。把所有的list的数放到一个list里,检测一下就好了。代码如下:

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  leetcode python matrix 2d