PracHub
QuestionsLearningGuidesInterview Prep
|Home/Coding & Algorithms/Lead

Process Calendar Events with Deletion, Pagination, and Overlap Queries

Last updated: Jul 22, 2026

Quick Overview

Practice implementing an in-memory calendar that supports inserts, deletions, stable ordering, zero-based pagination, and half-open interval overlap queries. The prompt tests careful operation parsing, deterministic tie-breaking, boundary semantics, and performance across a large command stream.

  • medium
  • Lead
  • Coding & Algorithms
  • Software Engineer

Process Calendar Events with Deletion, Pagination, and Overlap Queries

Company: Lead

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

# Process Calendar Events with Deletion, Pagination, and Overlap Queries Process operations against an in-memory calendar. Every event has a unique name, an integer start time, and an integer end time. Event intervals are half-open: `[start, end)`. ```python def process_calendar(operations: list[list[str]]) -> list[list[str]]: ... ``` Operations have these forms: - `["INSERT", name, start, end]`: add an event. The input guarantees that `name` is not already present and `int(start) < int(end)`. - `["DELETE", name]`: remove the named event if it exists; otherwise do nothing. - `["EVENTS"]`: output all current event names sorted by `(start, end, name)`. - `["PAGE", page_size, page_num]`: output one zero-based page from that same sorted order. Return an empty list when the page starts beyond the end. - `["OVERLAP", query_start, query_end]`: output the names of all events that intersect `[query_start, query_end)`, again sorted by `(start, end, name)`. The query interval is valid and non-empty. Arguments other than names are decimal integer strings. Return one list of names for each `EVENTS`, `PAGE`, or `OVERLAP` operation, in encounter order. ## Constraints - `0 <= len(operations) <= 200_000` - Times fit in signed 64-bit integers. - `1 <= page_size <= 10_000` and `page_num >= 0`. - Event names are non-empty ASCII strings. ## Example ```text Input: operations = [ ["INSERT", "review", "30", "50"], ["INSERT", "standup", "10", "20"], ["INSERT", "planning", "18", "35"], ["EVENTS"], ["PAGE", "2", "1"], ["OVERLAP", "19", "31"], ["DELETE", "planning"], ["EVENTS"] ] Output: [ ["standup", "planning", "review"], ["review"], ["standup", "planning", "review"], ["standup", "review"] ] ```

Quick Answer: Practice implementing an in-memory calendar that supports inserts, deletions, stable ordering, zero-based pagination, and half-open interval overlap queries. The prompt tests careful operation parsing, deterministic tie-breaking, boundary semantics, and performance across a large command stream.

Related Interview Questions

  • Process a Mutable Stock-Price Log - Lead (medium)
  • Solve friend recommendations and time-versioned maps - Lead (medium)
|Home/Coding & Algorithms/Lead

Process Calendar Events with Deletion, Pagination, and Overlap Queries

Lead logo
Lead
Jul 8, 2026, 12:00 AM
mediumSoftware EngineerOnsiteCoding & Algorithms
1
0

Process Calendar Events with Deletion, Pagination, and Overlap Queries

Process operations against an in-memory calendar. Every event has a unique name, an integer start time, and an integer end time. Event intervals are half-open: [start, end).

def process_calendar(operations: list[list[str]]) -> list[list[str]]:
    ...

Operations have these forms:

  • ["INSERT", name, start, end] : add an event. The input guarantees that name is not already present and int(start) < int(end) .
  • ["DELETE", name] : remove the named event if it exists; otherwise do nothing.
  • ["EVENTS"] : output all current event names sorted by (start, end, name) .
  • ["PAGE", page_size, page_num] : output one zero-based page from that same sorted order. Return an empty list when the page starts beyond the end.
  • ["OVERLAP", query_start, query_end] : output the names of all events that intersect [query_start, query_end) , again sorted by (start, end, name) . The query interval is valid and non-empty.

Arguments other than names are decimal integer strings. Return one list of names for each EVENTS, PAGE, or OVERLAP operation, in encounter order.

Constraints

  • 0 <= len(operations) <= 200_000
  • Times fit in signed 64-bit integers.
  • 1 <= page_size <= 10_000 and page_num >= 0 .
  • Event names are non-empty ASCII strings.

Example

Input:
operations = [
  ["INSERT", "review", "30", "50"],
  ["INSERT", "standup", "10", "20"],
  ["INSERT", "planning", "18", "35"],
  ["EVENTS"],
  ["PAGE", "2", "1"],
  ["OVERLAP", "19", "31"],
  ["DELETE", "planning"],
  ["EVENTS"]
]

Output:
[
  ["standup", "planning", "review"],
  ["review"],
  ["standup", "planning", "review"],
  ["standup", "review"]
]

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Lead•More Software Engineer•Lead Software Engineer•Lead Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 9,000+ real questions from top companies.

Product

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

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding 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.