func searchMatrix(matrix [][]int, target int) bool { if len(matrix) == 0 || len(matrix[0]) == 0 { return false } m, n := len(matrix) - 1, len(matrix[0]) - 1 i, j := m, 0 for i >= 0 && j <= n { if matrix[i][j] == target { return true } else if matrix[i][j] < target { j++ } else { i-- } } return false }
原文:https://www.cnblogs.com/dingxiaoqiang/p/14625979.html