Given an `m x n` matrix of **distinct** numbers, return all lucky numbers in the matrix in any order.
A **lucky number** is an element of the matrix such that it is the minimum element in its row and the maximum element in its column.
Given an m x n matrix of distinct numbers, return all lucky numbers in the matrix in any order.
A lucky number is an element of the matrix such that it is the minimum element in its row and the maximum element in its column.
Example 1:
Input: {"matrix":[[3,7,8],[9,11,13],[15,16,17]]}
Output: [15]
Constraints:
m=matrix.length, n=matrix[i].length
1≤n,m≤50
1≤matrix[i][j]≤105
All elements in the matrix are distinct.
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"matrix":[[3,7,8],[9,11,13],[15,16,17]]}
A lucky number is the smallest in its row and the largest in its column. With distinct values there can be at most one, and it must equal both the largest row minimum and the smallest column maximum.