dsa · medium

Search a 2D Matrix II

GreyOrangeArrayBinary Search

Each row **and** each column is sorted ascending. Return whether target is present.

Arguments

**Example**

`` Input: [[1,4,7,11],[2,5,8,12],[3,6,9,16],[10,13,14,17]] 5 Output: True ``

Constraints

1 <= m, n <= 100 Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.

Examples

Example 1

Input:
[[1,4,7,11],[2,5,8,12],[3,6,9,16],[10,13,14,17]]
5

Expected:
true

Example 2

Input:
[[1,4,7,11],[2,5,8,12],[3,6,9,16],[10,13,14,17]]
20

Expected:
false

Open in the Dojo editor