FunctionRacerProblemsRace

Lucky Numbers in a Matrix

EasyGridsPython, JavaScript, TypeScript, Java, C++

All numbers in matrix are different. A number is lucky if it is the smallest in its row and also the largest in its column.

Return all lucky numbers, in increasing order.

Example 1

matrix [[3,7,8],[9,11,13],[15,16,17]]
returns [15]

15 is the smallest in its row and the largest in its column.

Example 2

matrix [[1,10,4,2],[9,3,8,7],[15,16,17,12]]
returns [12]

12 is the smallest in its row and the largest in its column.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Grids problems