Answer: WORKSPAN Hiring | On-Campus OA (2022) | Lucky Numbers in a Matrix

Answer · Posted Jun 2026

Approach For every row: Find the minimum value and its column index. Check whether this value is also the maximum element in that column. If yes, add it to the result. Java Code import java.util.*; class Solution { public List<Integer> luckyNumbers(int[][] matrix) { int m = matrix.length; int n = matrix[0].length; List<Integer> result = new ArrayList<>(); for (int i = 0; i < m; i++) { int minVal = matrix[i][0]; int minCol = 0; for (int j = 1; j ...

The full answer & interview discussion are available to premium members.

Log in Create a free account