Tap here to switch tabs
Problem
Submissions

Problem: Search a 2D Matrix II

med
30 min
Try to solve the Search a 2D Matrix II problem.

Statement

Given an integer matrix matrix with m rows and n columns, determine whether the integer target exists in matrix.

The matrix has the following ordering properties:
Each row of matrix is sorted in ascending order from left to right.
Each column of matrix is sorted in ascending order from top to bottom.

Return true if target is present in matrix, otherwise return false.

Constraints:

  • m == matrix.length

  • n == matrix[i].length

  • 1n,m3001 \leq `n`, `m` \leq 300

  • 109matrix[i][j]109-10^9 \leq `matrix[i][j]` \leq 10^9

  • All the integers in each row are sorted in ascending order.

  • All the integers in each column are sorted in ascending order.

  • 109target109-10^9 \leq `target` \leq 10^9

Tap here to switch tabs
Problem
Submissions

Problem: Search a 2D Matrix II

med
30 min
Try to solve the Search a 2D Matrix II problem.

Statement

Given an integer matrix matrix with m rows and n columns, determine whether the integer target exists in matrix.

The matrix has the following ordering properties:
Each row of matrix is sorted in ascending order from left to right.
Each column of matrix is sorted in ascending order from top to bottom.

Return true if target is present in matrix, otherwise return false.

Constraints:

  • m == matrix.length

  • n == matrix[i].length

  • 1n,m3001 \leq `n`, `m` \leq 300

  • 109matrix[i][j]109-10^9 \leq `matrix[i][j]` \leq 10^9

  • All the integers in each row are sorted in ascending order.

  • All the integers in each column are sorted in ascending order.

  • 109target109-10^9 \leq `target` \leq 10^9