My first round got stood up, so I did the second one first. Overall it wasn't hard. It seems my approach was a bit different from the standard one, and the interviewer took a little while to understand it.
The question was roughly this: the input is two int sequences:
1, 2, 15, 8
2, 4, 7, 8
The goal is to decide whether they can be merged into a single sequence with no duplicate numbers, while keeping the relative order of the numbers in each original sequence unchanged.
After a bit of clarifying I could start working on it. They didn't ask about time or space complexity.
Then came the follow-ups: under what condition is the consolidation unique, and what single line in your loop would you change to check? After that they asked how to get the lexicographically minimal sequence and had me modify the code. At the end I walked through the code flow for [[1,2],[1,2]] out loud.
Discussion
Loading comments…