第一反应就是遍历:
# -*- coding:utf-8-*-
classSolution:
# array 二维列表
def Find(self, target, array):
# write code here
ifarray == [[]]:
returnFalse
fori in range(len(array)):
forj in range(len(array[i])):
ifarray[i][j] == target:
returnTrue
returnFalse
or
# -*- coding:utf-8-*-
classSolution:
# array 二维列表
def Find(self, target, array):
# write code here
ifarray == [[]]:
returnFalse
fori in array:
forj in i:
ifj == target:
returnTrue
returnFalse