Skip to interview prep
Apexed

68. Search a Row- and Column-Sorted Matrix

MediumSearching

Each row and each column of matrix is sorted ascending. Return true if target is present, in O(rows + columns).

Example 1

Input: matrix = [[1, 4, 7], [2, 5, 8], [3, 6, 9]], target = 5
Output: true

Constraints

  • 1 ≤ rows, columns ≤ 300

Tab indents · Ctrl/⌘ + Enter runs · Esc then Tab leaves the editor

Run checks these cases; the expected output comes from the reference solution. Submit judges all 4 hidden and sample tests.

Code runs only in your browser in an isolated sandbox. Progress and submissions are saved on this device.

Search a Row- and Column-Sorted Matrix — coding interview practice — Apexed