Algorithm · Goldman Sachs · Medium
You are given a two-dimensional integer array matrix with m rows and n columns, together with a single integer target. Decide whether target appears anywhere inside matrix. In every row, entries are non-decreasing when read from left to right. Likewise, in every column, entries are non-decreasing when read from top to bottom. Use a staircase search: start at the upper-right or lower-left corner and repeatedly eliminate one row or one column based on the current value. The…
Checking your access…