Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

row and column sorted matrix

// Search a 2D Matrix II
// https://leetcode.com/problems/search-a-2d-matrix-ii
class Solution {
    public boolean searchMatrix(int[][] matrix, int target) {
        int row = 0;
        int col = matrix[0].length-1;
        
        while (row < matrix.length && col >= 0){
            if (matrix[row][col] == target) return true;
            if (matrix[row][col] < target) row++;
            else if (matrix[row][col] > target) col--;
        }
       return false;
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: compare two strings java 
Java :: java float precision 
Java :: create thread 
Java :: string program to calculate number of characters in a string java 
Java :: extract substring in string java 
Java :: explain java coding standards for classes 
Java :: biginteger modulo in java 
Java :: Access HashMap Elements 
Java :: java 8 stream add to list 
Java :: multiple root tags android manifest 
Java :: schantalgebra 
Java :: java dato numero big starkoverflow 
Java :: java manipulate alphabet list 
Sql :: PROSYS SQL BKP 
Sql :: alter session set nls_date_format 
Sql :: alter user mysql native password 
Sql :: mysql get date difference in hours 
Sql :: Enter into postgresql database,create user and grant Access 
Sql :: sql list all procedures 
Sql :: postgresql add enum value 
Sql :: create table in postgresql 
Sql :: how to change potgress password 
Sql :: log queries postgre 
Sql :: Found option without preceding group in config file: /etc/mysql/mariadb.conf.d/50-server.cnf at line: 1 
Sql :: postgres sequence name 
Sql :: how to export db from mysql 
Sql :: mysql timestamp in laravel migration 
Sql :: oracle sql first day of month 
Sql :: sql check roles 
Sql :: mysql monthname 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =