Find Smallest Common Row Value
Company: SoFi
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: easy
Interview Round: Technical Screen
Quick Answer: This question evaluates algorithmic problem-solving skills focused on array processing, intersection across multiple sorted sequences, and time/space complexity analysis.
Constraints
- 1 <= number of rows <= 1000
- 1 <= number of columns <= 1000
- All rows have the same length
- Each row is sorted in strictly increasing order
- -10^9 <= matrix[i][j] <= 10^9
Examples
Input: ([[1,2,3,4,5],[2,4,5,8,10],[3,5,7,9,11],[1,3,5,7,9]],)
Expected Output: 5
Explanation: The value 5 appears in every row, and no smaller value does.
Input: ([[-4,-1,0,9]],)
Expected Output: -4
Explanation: With only one row, every value in that row appears in every row. The smallest is -4.
Hints
- Any valid answer must come from the first row, so you can test its values from left to right.
- Since every row is sorted, use binary search to check whether a candidate appears in the other rows.