All values in matrix are distinct. A value is lucky when it is the smallest entry in its row and the largest entry in its column. Return an array containing every lucky value, in any order. Return an empty array if no value satisfies both conditions.
Example 1:
Input: matrix = [[8]]
Output: [8]Explanation: The only entry is both the minimum of its row and the maximum of its column, so return [8].
Example 2:
Input: matrix = [[4,9],[7,12]]
Output: [7]Explanation: The value 7 is smaller than 12 in its row and larger than 4 in its column. No other value meets both conditions.
Example 3:
Input: matrix = [[1,4],[3,2]]
Output: []Explanation: The row minima are 1 and 2. The first column contains 3, which is greater than 1, and the second contains 4, which is greater than 2, so neither row minimum is a column maximum. Return an empty array.
Constraints:
- Each dimension is between
1and50; all rows have equal length. 1 <= matrix[i][j] <= 100000- All values in the matrix are distinct.