Trains the technique from
LeetCode 1380Lucky Numbers in a MatrixThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A panel of readings is given as matrix, and no two readings anywhere on it are equal.
A reading is standout when it is the smallest in its own row and, at the same time, the largest in its own column.
Return every standout reading, listed in the order their rows appear.
Example 1
The reading 24 is the smallest of its row, whose other entries are 30 and 35, and the largest of its column, whose other entries are 2 and 11.
Example 2
The row smallests are 4, 3 and 10, while the column largests are 25, 21 and 18. Nothing appears in both lists, so no reading stands out.
Example 3
The reading 4 is smaller than the 9 beside it and larger than the 1 below it.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def lucky_numbers(matrix: list[list[int]]) -> list[int]:public List<Integer> luckyNumbers(int[][] matrix)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.