Ctrl K

Row Low, Column High

Easy
You are given a rectangular table grid whose numbers are all distinct. Find every number that is both the smallest in its row and the largest in its column. Return them in any order; if there are none, return an empty list.
Example 1
grid=[[4, 9, 6], [12, 10, 15], [2, 8, 1]] → [10]

10 is the smallest in its row [12, 10, 15] and the largest in its column [9, 10, 8].

Example 2
grid=[[3, 1], [2, 4]] → []

The row minimums are 1 and 2, but 1 is not the top of its column [1, 4], and 2 is not the top of [3, 2]. The answer is empty.

Example 3
grid=[[5, 7, 3]] → [3]
Constraints
  • 1 ≤ number of rows, number of columns ≤ 50
  • 1 ≤ grid[i][j] ≤ 10⁵
  • All numbers in the table are distinct
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsCrossword That Reads Both Ways EasyIsland Coastline Length EasyRepack the Tray EasyBlur the Pixels EasyPaint Bucket Tool Easy
loading Python…
Input
grid=[[4, 9, 6], [12, 10, 15], [2, 8, 1]]
Expected
[10]

Run checks the first 3 tests in your browser. Submit checks all 63 tests on the server, hidden ones included.