Smallest Intersecting Element
You are given a two-dimensional list of integers matrix
where each row is sorted in ascending order. Return the smallest number that exists in every row. If there’s no solution, return -1
.
Constraints
n, m ≤ 250
wheren
andm
are the number of rows and columns inmatrix
https://binarysearch.com/problems/Smallest-Intersecting-Element
Examples
Example 1
Input
- matrix =
[[1,2,4],
[4,9,9],
[0,2,4]]
Output
- answer =
4
Leave a comment