Google Phone Screening Round - L5

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2025-04-15Added By Anonymous
Source: Link

You have sequence array, each sequence has some value in order. You have to create a result

where order of sequence stays as it is.


Ex - [

[1,2,15,8],

[2,4,7,8],

[2,3,7,15]

]


Output - 1,2,3,4,7,15,8 or 1,2,4,3,7,15,8


False case - [[1,6,4], [4,1]] -


Solved this using toposort. Created an adjList and indegree matrix and traversed the list to get the result array.


For false case, checked if the cycle exists

Comments