Merge Staff Shifts Into Who-Is-On-Duty Time Slots

Algorithm · Square · Medium

You are given a work schedule for one day: for every person, the time they start and the time they finish. Split the day into a sequence of back-to-back time ranges. Pair each range with exactly the group of people who are on shift throughout that range, and return the resulting list of (range, set of people) entries. Examples Example

Loading the rest of the question…