Back to course home
0% completed
Solution: Search a 2D Matrix II
Problem Statement
Given a 2D grid of size m x n
matrix
containing integers, and integer target
, return true
if target
value exists in the matrix
. Otherwise, return false.
The matrix
has the following properties:
- Values in each column are sorted in
non-decreasing order
fromtop to bottom
. - Values in each row are sorted in
non-decreasing order
fromleft to right
.
Examples
Example 1:
- Input: target = 5, matrix =
[[1,2,3],
[4,5,6],
[7,8,9]]
- Expected Output:
true
.....
.....
.....
Like the course? Get enrolled and start learning!