题解 | #二维数组中的查找#
二维数组中的查找
http://www.nowcoder.com/practice/abc3fe2ce8e146608e868a70efebf62e
package main
func Find( target int , array [][]int ) bool {
row := len(array) //数组的行数
column := len(array[0]) //数组的列数
for x, y := 0, column - 1; x < row && y >= 0; { //从右上角的点开始遍历
if array[x][y] < target { //比它大的点都在它下边
x ++
continue
}
if array[x][y] > target { //比它小的点都在它左边
y --
continue
}
if array[x][y] == target {
return true
}
}
return false
}