PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates interval conflict detection and efficient range storage skills, assessing algorithm design and data structure competency within the Coding & Algorithms domain.

  • medium
  • Microsoft
  • Coding & Algorithms
  • Software Engineer

Implement a calendar with non-overlapping bookings

Company: Microsoft

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

## Problem Design a calendar booking system that stores half-open time intervals `[start, end)` (inclusive of `start`, exclusive of `end`). Implement a class with a method: - `book(start, end) -> boolean` The method should: - Return `true` and add the event if it does **not** overlap with any existing event. - Return `false` and do **not** add the event if it overlaps with an existing event. Two events `[s1, e1)` and `[s2, e2)` overlap iff `max(s1, s2) < min(e1, e2)`. ### Example Operations: - `book(10, 20)` → `true` - `book(15, 25)` → `false` (overlaps with `[10,20)`) - `book(20, 30)` → `true` (touching at 20 is allowed) ### Constraints (typical) - Up to `10^3` to `10^5` bookings - `0 <= start < end <= 10^9`

Quick Answer: This question evaluates interval conflict detection and efficient range storage skills, assessing algorithm design and data structure competency within the Coding & Algorithms domain.

Process half-open interval bookings and return whether each booking is accepted.

Constraints

  • 0 <= start < end

Examples

Input: ([(10, 20), (15, 25), (20, 30)],)

Expected Output: [True, False, True]

Explanation: Touching at the endpoint is allowed.

Input: ([(5, 10), (1, 5), (10, 15)],)

Expected Output: [True, True, True]

Explanation: Sorted insertion around neighbors.

Input: ([(1, 2), (2, 3), (1, 3)],)

Expected Output: [True, True, False]

Explanation: Later interval can overlap two accepted bookings.

Hints

  1. Only the predecessor and successor in start-time order can overlap a new interval.
Last updated: Jun 27, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ 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.

Related Coding Questions

  • Return Top K Open Businesses - Microsoft (hard)
  • Implement Memory Allocation and In-Memory Records - Microsoft (medium)
  • Implement K-Means and Detect Divisible Subarrays - Microsoft (medium)
  • Sort Three Categories In Place - Microsoft (medium)
  • Retain Top K Elements - Microsoft (medium)