Search⌘ K
AI Features

Solution: Lucky Numbers in a Matrix

Understand how to find lucky numbers in a matrix, where the number is smallest in its row and largest in its column. Explore a greedy algorithm that efficiently compares row minimums and column maximums to solve this problem with optimal time and space complexity.

Statement

Given an m×nm \times n matrix of distinct numbers, return the lucky number in the matrix.

lucky number is an element of the matrix such that it is the smallest element in its row and largest in its column.

Constraints:

  • m= ...