The interviewer was very friendly and helpful. I found the coding question challenging, but the interviewer provided assistance when I struggled.
The Coding Question:
Given a list of sequences input, reconstruct a shortest common supersequence of the sequences in input (i.e. a shortest sequence so that all the sequences in input are subsequences of it). If there are multiple supersequences, just return one valid answer.
// Example 1:
// Input = [[1,2],[1,3]]
// Output: [1,2,3] or [1,3,2]
// Example 3: // Input = [[5,2,6,3],[4,1,5,2]] // Output: [4,1,5,2,6,3] // Example 4: // Input = [[1,4,5], [2,5,3]] // Output = [1,4,2,5,3] or [1,2,4,5,3] or [2,1,4,5,3] //
Solution:
You have to create a HashMap of the values and its dependencies. And a HashSet of of solutions.