Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Search a 2D Matrix

Medium Matrix

A matrix has each row sorted left to right and the first element of each row greater than the last element of the previous row. Print true if the target exists in the matrix, otherwise false. Required time: O(log(R * C)).

Constraints

1 <= R, C <= 100 -10^4 <= value, target <= 10^4

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.