#coding:utf-8
#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
#
# @param mat int整型二维数组
# @param n int整型
# @param m int整型
# @param x int整型
# @return int整型一维数组
#
class Solution:
def findElement(self , mat , n , m , x ):
# write code here
#init
#思路:从右上角开始搜索
row, col = 0, m - 1
while row < n and col >= 0:
if mat[row][col] == x:
return [row, col]
elif mat[row][col] > x:
col -= 1
else:
row += 1
return [-1, -1]

京公网安备 11010502036488号