(Solution) Naive 1ms Java


  • 0
    M
        public boolean searchMatrix(int[][] matrix, int target) {
            for(int i=0;i<matrix.length;i++){
                int num = matrix[i][matrix[i].length-1];
                if(num<target){
                    continue;
                }
                for(int j=0;j<matrix[i].length;j++){
                    if(matrix[i][j]==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.