Uber India interview question

1175
Jan 27, 2023

Consolidate Security Gaurd Shifts

A list of individual security guard shifts will be provided as input in the format [tStart, tEnd, name].

Return a consolidated list in such a way that no timestamp is overlapped.


Input

1 - 10 | S 1
1 - 15 | S 2
1 - 13 | S 5
3 - 7 | S 3
12 - 15 | S 4

Output

1 - 3 | S 1, S 2, S 5
3 - 7 | S 1, S 2, S 5, S 3
7 - 10 | S 1, S 2, S 5
10 - 12 | S 5, S 2
12 - 13 | S 5, S 2, S 4
13 - 15 | S 4, S 2

Comments (3)