← SoFi Interview Insights

SoFi·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Coding screen for a Software Engineer role at SoFi. The main problem was a matrix search question and they also wanted you to think through edge cases and write test cases on the spot, which I wasn't fully expecting.

Questions Asked (1)

Q1

Given a 2D matrix where each row is sorted in strictly increasing order, find the smallest integer that appears in every row. Return -1 if no such integer exists.

Algorithms & Data Structures
Author's notes

The example they gave made it pretty obvious the answer was 5 since it showed up in all four rows.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the problem constraints and edge cases, then propose an efficient algorithm such as binary search on the first row or a k-way merge with a min-heap. Analyze time and space complexity, and discuss trade-offs between different approaches.

Pro tip: Mention that since each row is sorted, you can use binary search to check for the presence of a candidate in each row, leading to O(m log n) time, which is optimal for large matrices. Also, consider early termination if a row's smallest element exceeds the current candidate.

1. Clarify constraints and edge cases

Ask about matrix dimensions, value ranges, and whether rows can be empty. Discuss what to return if no common element exists.

2. Propose a brute-force baseline

Start with a simple approach: iterate through the first row and for each element, check its presence in all other rows using binary search. This gives O(m * n log n) time.

3. Optimize with binary search on the first row

Since the first row is sorted, use binary search to find the smallest element that appears in all rows. For each candidate, check other rows with binary search, achieving O(m log n) time.

4. Consider alternative approaches

Discuss a k-way merge using a min-heap to find common elements, or using hash sets for O(m*n) time but O(n) space. Compare trade-offs.

5. Analyze complexity and test

State time and space complexity of the chosen solution. Walk through an example and test edge cases like single row, no common element, and large matrices.

Key Points to Mention

  • Binary search on sorted rows for efficient membership check
  • Time complexity: O(m log n) with binary search, O(m*n) with brute force
  • Space complexity: O(1) extra space for binary search approach
  • Edge cases: empty matrix, single row, no common element
  • Early termination: if current candidate is less than the first element of a row, it cannot be common
  • Trade-offs between different approaches (e.g., hash set vs binary search)

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.