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.
- Find the min of each row and store in an array.
- Find the max of each column and store in an array.
- If an element exists in both result arrays, print it.
01EXAMPLE 1
Input
[[3,7,8],[9,11,13],[15,16,17]]Output
15Explanation: 15 is min in row 2 and max in col 0.
Constraints
- Single/Double pass O(m*n).
MatrixLogic
JavaScriptSystem handles I/O — write your function only
Loading...
1 Hidden
Input Arguments
matrix[[3,7,8],[9,11,13],[15,16,17]]
Expected Output
15
Click RUN to test your solution