Lucky Numbers in Matrix

MediumAcc. 92.1%
+30 XP 10

Cross-Axis Optimization

A lucky number must be the smallest in its row AND the largest in its column.

The Assignment

Your function receives matrix.

  1. Find the min of each row and store in an array.
  2. Find the max of each column and store in an array.
  3. If an element exists in both result arrays, print it.

01EXAMPLE 1

Input[[3,7,8],[9,11,13],[15,16,17]]
Output15

Explanation: 15 is min in row 2 and max in col 0.

Constraints

  • Single/Double pass O(m*n).
MatrixLogic
JavaScript
Loading...
1 Hidden

Input Arguments

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

Expected Output

15

Click RUN to test your solution