As reported: Goldman Sachs Associate SWE Superday, DSA round 1 (2026): a "staircase" search problem, the first of two questions.
Each row of matrix is sorted left to right and each column top to bottom. Return true if target occurs in the matrix.
This is LeetCode 240 — Search a 2D Matrix II.
Example 1
matrix = [[1,4,7,11,15],[2,5,8,12,19],[3,6,9,16,22],[10,13,14,17,24],[18,21,23,26,30]], target = 5
-> true
Example 2
matrix = [[1,4,7,11,15],[2,5,8,12,19],[3,6,9,16,22],[10,13,14,17,24],[18,21,23,26,30]], target = 20
-> false
Constraints: 1 ≤ m, n ≤ 300; -10^9 ≤ matrix[i][j], target ≤ 10^9.
Code runner format: one JSON value per line: matrix, then target (LeetCode's test-case format). Implement searchMatrix(matrix, target); the harness prints the result as JSON.