PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Pinterest

Find available reservation time slots

Last updated: May 10, 2026

Quick Overview

This question evaluates a candidate's ability to reason about time-interval data and temporal normalization, testing competencies in interval manipulation, conflict detection, and algorithmic problem-solving for scheduling contexts.

  • Medium
  • Pinterest
  • Coding & Algorithms
  • Data Scientist

Find available reservation time slots

Company: Pinterest

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Onsite

## Problem You are building an API to show which time slots are available for booking at a restaurant. You are given: - The restaurant’s **opening hours** (per day), and - A list of **existing reservations** (per day), each with a start and end time. Opening hours and reservations are provided in a **nested dictionary** structure. ### Input Assume times are in the same timezone and represented as minutes-from-midnight or as `HH:MM` strings that can be converted to minutes. - `hours[day] = [open_time, close_time]` - `reservations[day] = [[start1, end1], [start2, end2], ...]` Example shape: ```python hours = { "Mon": ["11:00", "22:00"], "Tue": ["11:00", "22:00"], } reservations = { "Mon": [["12:00", "12:30"], ["18:00", "19:15"]], "Tue": [], } ``` ### Task Write a function that returns, for each day, the list of **available time intervals** within opening hours that are not blocked by existing reservations. Clarify/handle these cases: - Reservations may be unsorted. - Reservations may touch endpoints (e.g., one ends at 13:00 and another starts at 13:00). - If reservations overlap, they should be merged before computing availability. ### Output Return a nested dictionary: - `available[day] = [[free_start1, free_end1], [free_start2, free_end2], ...]` (Optionally, if a booking duration `D` minutes is provided, return only free intervals of length `>= D`, or return discrete start times valid for a `D`-minute reservation—state your choice.)

Quick Answer: This question evaluates a candidate's ability to reason about time-interval data and temporal normalization, testing competencies in interval manipulation, conflict detection, and algorithmic problem-solving for scheduling contexts.

Related Interview Questions

  • Design Hierarchical Permission Checks - Pinterest (medium)
  • Implement weighted random choice - Pinterest (medium)
  • Solve five hard algorithm problems - Pinterest
  • Sample a string by real-valued scores - Pinterest (hard)
  • Find First Prefix-Matching Word - Pinterest (medium)
Pinterest logo
Pinterest
Aug 2, 2025, 12:00 AM
Data Scientist
Onsite
Coding & Algorithms
8
0

Problem

You are building an API to show which time slots are available for booking at a restaurant.

You are given:

  • The restaurant’s opening hours (per day), and
  • A list of existing reservations (per day), each with a start and end time.

Opening hours and reservations are provided in a nested dictionary structure.

Input

Assume times are in the same timezone and represented as minutes-from-midnight or as HH:MM strings that can be converted to minutes.

  • hours[day] = [open_time, close_time]
  • reservations[day] = [[start1, end1], [start2, end2], ...]

Example shape:

hours = {
  "Mon": ["11:00", "22:00"],
  "Tue": ["11:00", "22:00"],
}

reservations = {
  "Mon": [["12:00", "12:30"], ["18:00", "19:15"]],
  "Tue": [],
}

Task

Write a function that returns, for each day, the list of available time intervals within opening hours that are not blocked by existing reservations.

Clarify/handle these cases:

  • Reservations may be unsorted.
  • Reservations may touch endpoints (e.g., one ends at 13:00 and another starts at 13:00).
  • If reservations overlap, they should be merged before computing availability.

Output

Return a nested dictionary:

  • available[day] = [[free_start1, free_end1], [free_start2, free_end2], ...]

(Optionally, if a booking duration D minutes is provided, return only free intervals of length >= D, or return discrete start times valid for a D-minute reservation—state your choice.)

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Pinterest•More Data Scientist•Pinterest Data Scientist•Pinterest Coding & Algorithms•Data Scientist Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.