Skip to content

Latest commit

 

History

History
24 lines (21 loc) · 429 Bytes

240.md

File metadata and controls

24 lines (21 loc) · 429 Bytes

Search a 2D Matrix II

解法一

func searchMatrix(matrix [][]int, target int) bool {
    if len(matrix) == 0 {
        return false
    }
    col,row := 0,len(matrix[0])-1

    for col < len(matrix) && row >= 0 {
         t := matrix[col][row]
        if target == t{
            return true
        }else if target < t  {
            row --
        }else {
           col ++
        }
    }
    return false
}