https://leetcode-cn.com/problems/er-wei-shu-zu-zhong-de-cha-zhao-lcof/submissions/
func findNumberIn2DArray(_ matrix: [[Int]], _ target: Int) -> Bool {
if matrix.isEmpty || matrix[0].isEmpty {return false}
var row = 0
var column = matrix[0].count - 1
while row < matrix.count && column >= 0 {
let value = matrix[row][column]
if value == target {
return true
} else if (value > target) {
column = column - 1
} else {
row = row + 1
}
}
return false
}
网友评论