java.lang.Object
g1301_1400.s1380_lucky_numbers_in_a_matrix.Solution

public class Solution extends Object
1380 - Lucky Numbers in a Matrix.<p>Easy</p> <p>Given an <code>m x n</code> matrix of <strong>distinct</strong> numbers, return <em>all <strong>lucky numbers</strong> in the matrix in <strong>any</strong> order</em>.</p> <p>A <strong>lucky number</strong> is an element of the matrix such that it is the minimum element in its row and maximum in its column.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> matrix = [[3,7,8],[9,11,13],[15,16,17]]</p> <p><strong>Output:</strong> [15]</p> <p><strong>Explanation:</strong> 15 is the only lucky number since it is the minimum in its row and the maximum in its column.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> matrix = [[1,10,4,2],[9,3,8,7],[15,16,17,12]]</p> <p><strong>Output:</strong> [12]</p> <p><strong>Explanation:</strong> 12 is the only lucky number since it is the minimum in its row and the maximum in its column.</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> matrix = [[7,8],[1,2]]</p> <p><strong>Output:</strong> [7]</p> <p><strong>Explanation:</strong> 7 is the only lucky number since it is the minimum in its row and the maximum in its column.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>m == mat.length</code></li> <li><code>n == mat[i].length</code></li> <li><code>1 <= n, m <= 50</code></li> <li><code>1 <= matrix[i][j] <= 10<sup>5</sup></code>.</li> <li>All elements in the matrix are distinct.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • luckyNumbers

      public List<Integer> luckyNumbers(int[][] matrix)