← Nextdoor Interview Insights

Nextdoor·Machine Learning Engineer·Technical Phone Screen·Senior

SeniorPrefer not to say
May 2026

Summary

Coding round at Nextdoor for an MLE role. One problem, a twist on the classic merge intervals, but with weekday-aware timestamps. The conversion trick is clean once you see it, but I fumbled around longer than I should have before landing on it.

Questions Asked (1)

Q1

Given a list of time intervals where each interval includes a weekday (Monday through Sunday), a start time, and an end time in HH:MM format, merge all overlapping intervals. Intervals can span across consecutive weekdays.

Algorithms & Data Structures
Author's notes

The key move is flattening everything onto a single integer timeline: multiply the weekday index by 24*60, then add the minutes from HH:MM.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Normalize each interval to a linear timeline (e.g., minutes since Monday 00:00), sort by start time, then merge overlapping intervals by comparing current end with next start. Handle week-spanning intervals by allowing end times to exceed 7 days and converting back to weekday/time format after merging.

Pro tip: Clarify edge cases upfront: whether intervals are inclusive/exclusive, if zero-length intervals are allowed, and if input is sorted. This shows attention to detail and prevents wrong assumptions.

1. Clarify requirements and edge cases

Ask about interval inclusivity, zero-length intervals, input sorting, and output format. Confirm how to handle intervals that wrap around the week (e.g., Sunday 23:00 to Monday 01:00).

2. Normalize intervals to a linear timeline

Convert each interval to start and end minutes relative to Monday 00:00. For intervals spanning multiple days or wrapping around the week, compute the end time by adding days as needed to ensure end > start.

3. Sort intervals by start time

Sort the normalized intervals by their start time. This allows a single pass to merge overlapping intervals.

4. Merge overlapping intervals

Iterate through sorted intervals, merging if the current interval's start is less than or equal to the previous merged interval's end. Update the end to the maximum of the two ends.

5. Convert back to weekday and HH:MM format

For each merged interval, convert the start and end minutes back to weekday and time. If an interval spans more than 7 days, split it into multiple week-long intervals or handle as per requirements.

Key Points to Mention

  • Normalization to a linear timeline (e.g., minutes since Monday 00:00) simplifies merging and handles week boundaries.
  • Sorting by start time is crucial for an efficient O(n log n) merge algorithm.
  • Merging condition: if current start <= previous end, intervals overlap; update end to max(previous end, current end).
  • Handling intervals that span across week boundaries by allowing end times to exceed 7 days and then converting back.
  • Time complexity: O(n log n) due to sorting, O(n) for merging; space complexity O(n) for output.
  • Edge cases: zero-length intervals, intervals that exactly touch (e.g., end == start), and intervals that cover the entire week.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.