Simple Java code search


  • 0
    H
     if(target<matrix[0][0]||target>matrix[matrix.length-1][matrix[0].length-1]) return false;
            for(int i=0;i<matrix.length;i++){
                if(target>=matrix[i][0]&&target<=matrix[i][matrix[i].length-1]){
                   for(int k=0;k<matrix[i].length;k++){
                       if(matrix[i][k]==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.