Facebook(Meta) |Phone | Interview

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2021-12-10Added By Anonymous
Source: Link

Company: Meta (Facebook)
Role: unknown
Interview Stage: Phone Screen
Location: unknown
Year: unknown

Original Post Content:

Given an array that contains contiguous segments that are sorted, return a sorted array.

Example: [1,3,5,2,4,20,12]

has the following segments: [1,3,5],[2,4,20],[12] which are all sorted

How can we return a sorted array?

I used a heap and then added the first elements of each segment (after calculating the segments). Feel free to share your approach!

Comments