Search⌘ K
AI Features

Solution: Search a 2D Matrix II

C# solution for the Search a 2D Matrix II problem using the Two Pointers pattern.

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 ...