My normal solution


  • 0
    S

    public class Solution {
    public boolean searchMatrix(int[][] matrix, int target) {

        if(matrix.length==0&&matrix[0].length==0) {
            return false;
        }
        
        for(int i=0;i<matrix[0].length;i++) {
            if(matrix[matrix.length-1][i]>=target) {
                for(int j=0; j <matrix.length;j++) {
                    if(matrix[j][i]==target) {
                        return true;
                    }
                }
            }
        }
       return false; 
    }
    

    }


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.