Quick Overview

This question evaluates understanding of interval-merging algorithms and temporal data normalization, testing competency in handling time-based ranges, overlap detection, and chronological ordering within the Coding & Algorithms domain.

Merge Weekly Time Intervals

Company: Nextdoor

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

You are given a list of time intervals within a single week. Each time is written as a day-of-week plus a 24-hour clock, for example `Sat 13:00` or `Mon 09:30`. Each interval has the form `[start, end]`, where `start` and `end` are timestamps in the same weekly timeline, and `start <= end`. Write a function that merges all overlapping intervals and returns the merged result in chronological order. Example input: - `[Mon 09:00, Mon 11:00]` - `[Mon 10:30, Mon 12:00]` - `[Sat 13:00, Sat 14:00]` - `[Sat 13:30, Sat 15:00]` Example output: - `[Mon 09:00, Mon 12:00]` - `[Sat 13:00, Sat 15:00]` You should explain how to parse the weekday/time format into a comparable numeric value, then apply interval merging efficiently.

Quick Answer: This question evaluates understanding of interval-merging algorithms and temporal data normalization, testing competency in handling time-based ranges, overlap detection, and chronological ordering within the Coding & Algorithms domain.

Parse weekly day/time intervals, merge overlapping intervals, and return the merged intervals in chronological order.

Constraints

  • Inputs are provided as Python literals matching the function signature.
  • Return a deterministic exact-match result.

Examples

Input: ([['Mon 09:00','Mon 11:00'], ['Mon 10:30','Mon 12:00'], ['Sat 13:00','Sat 14:00'], ['Sat 13:30','Sat 15:00']],)

Expected Output: [['Mon 09:00', 'Mon 12:00'], ['Sat 13:00', 'Sat 15:00']]

Explanation: Prompt example.

Input: ([['Sun 23:00','Sun 23:30'], ['Mon 00:00','Mon 01:00']],)

Expected Output: [['Mon 00:00', 'Mon 01:00'], ['Sun 23:00', 'Sun 23:30']]

Explanation: Chronological week order.

Hints

  1. Choose a representation that makes the core operation simple.
  2. Handle empty and boundary inputs before the main algorithm.

Loading coding console...