Microsoft Onsite Question

Anonymous User
1479
Sep 20, 2023

I got the following question in my onsite interview with Microsoft:

Given a matrix of 2 by N of integers, select one integer from each column so that they are distinct.

I could only think and code up a backtracking based solution which had exponential time complexity and O(N) space complexity. What's the most optimal solution in terms of time complexity for this?

Thanks in advance!

Comments (6)