查找矩阵的元素,返回的是元素的下标,【1,2】下标的是6,从0开始算的下标。
class Solution:
def findElement(self, mat, n, m, x):
# write code here
for i in range(n):
for j in range(m):
# print(mat[i][j])//
if mat[i][j] == x:
return [i,j]//不能新建ans=[],不能返回ans.append,原因还在找
return None
京公网安备 11010502036488号