FastPrepCalendar Event System with Pagination and Intersection
Problems/Calendar Event System with Pagination and Intersection

Calendar Event System with Pagination and Intersection

Lead Bank logoLead Bank● MediumONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Lead Bank onsite interview. The report gives the Calendar operations. It does not give the exact output format, what to do with duplicate names, how to break ties in the order, how pages are numbered, whether interval ends are included, or the limits. We chose those. Our version is about 90% the same as the reported question.

Implement a calendar that stores active named events. Process each row in operations and append one string array to the result:

  • ["INSERT", name, start, end]: Insert the half-open event interval [start, end). Active event names are unique. Return ["true"] on success or ["false"] if that name already exists.
  • ["DELETE", name]: Delete the active event with that name. Return ["true"] on success or ["false"] if it does not exist. A deleted name may be inserted again later.
  • ["LIST", pageSize, pageNum]: Sort all active events by start time, then end time, then name, all ascending. Return the names on the one-based page. If that page starts beyond the list, return an empty array.
  • ["INTERSECT", queryStart, queryEnd]: Return the names of all active events whose half-open intervals intersect [queryStart, queryEnd), in the same sorted order. Two intervals intersect exactly when eventStart < queryEnd and queryStart < eventEnd.

Different events may overlap. Return one row per operation in input order.

Function

processCalendarOperations(operations: String[][]) → String[][]

Examples

Example 1

operations = [["INSERT","standup","10","11"],["INSERT","focus","9","12"],["INSERT","lunch","12","13"],["LIST","2","1"],["INTERSECT","10","12"],["DELETE","standup"],["LIST","5","1"]]return = [["true"],["true"],["true"],["focus","standup"],["focus","standup"],["true"],["focus","lunch"]]

Sorted order is focus, standup, lunch. The interval [10, 12) intersects the first two events but not lunch, which starts exactly at the query's excluded endpoint. After deleting standup, two events remain.

Example 2

operations = [["INSERT","a","1","3"],["INSERT","b","3","5"],["INSERT","c","2","4"],["LIST","1","2"],["INTERSECT","3","4"],["DELETE","missing"],["INSERT","a","6","7"]]return = [["true"],["true"],["true"],["c"],["c","b"],["false"],["false"]]

The second one-item page contains c. Event a ends at 3 and therefore does not intersect [3, 4); c and b do. Deleting an absent name and reinserting an active name both fail without changing state.

Constraints

  • 1 <= operations.length <= 10^4
  • Event names are non-empty and contain only ASCII letters, digits, hyphens, or underscores.
  • Every time is an integer in [0, 10^9].
  • Every inserted event and intersection query satisfies start < end.
  • Every pageSize and pageNum is a positive integer.
  • Every operation has one of the documented shapes.

More Lead Bank Onsite Interview questions

  • Stock System with Updates and Percentage ChangeONSITE INTERVIEW · Seen Jul 2026

Similar questions at other companies

  • Worker Management with Promotions and Double-Paid TimeInstacart · ONSITE INTERVIEWInstacart interview questions
  • Worker Management (Promotion Track), Part 4: Full-Shift Double PayAirbnb · OAAirbnb interview questions
  • Worker Management, Part 4: Double-Paid IntervalsAnthropic · OAAnthropic interview questions
  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • Camel CardsRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
  • Banking System with Top ActivityCapital One · ONSITE INTERVIEWCapital One interview questions
  • CD Rental SystemOkta · ONSITE INTERVIEWOkta interview questions
  • Order Manager with Partial Cancellations and Indexed QueriesStripe · ONSITE INTERVIEWStripe interview questions
  • Set Command SimulationPure Storage · ONSITE INTERVIEWPure Storage interview questions
  • Recipe Rating ServiceNubank · PHONE SCREEN
All Lead Bank interview questionsSee Lead Bank hiring insights
Saved
class Solution {
    public String[][] processCalendarOperations(String[][] operations) {
        // write your code here
    }
}
Checking account…