PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Microsoft

Implement a calendar with non-overlapping bookings

Last updated: Mar 29, 2026

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.

Related Interview 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)
Microsoft logo
Microsoft
Nov 25, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
10
0

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

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Microsoft•More Software Engineer•Microsoft Software Engineer•Microsoft Coding & Algorithms•Software Engineer 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.