FastPrepSchedule Tasks with an Interval Tree
Problems/Schedule Tasks with an Interval Tree

Schedule Tasks with an Interval Tree

LinkedIn logoLinkedIn● MediumFULLTIMEONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: The source names an interval-tree task-scheduling exercise but omits operation types, boundary semantics, output encoding, deterministic ordering, examples, and bounds. This BOOK/CONFLICTS judged contract is an approximately 65% match.

Process the ordered scheduling operations in operations. The calendar starts empty, and every time interval is half-open: [start, end).

  • BOOK id start end: If the interval overlaps any accepted booking, leave the calendar unchanged and append false. Otherwise accept it and append true.
  • CONFLICTS start end: Append the comma-separated IDs of all accepted bookings that overlap the query, ordered by booking start. Append an empty string when none overlap.

Two half-open intervals overlap exactly when leftStart < rightEnd and rightStart < leftEnd. Each BOOK ID is unique across the input.

Function

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

Examples

Example 1

operations = ["BOOK focus 9 10","BOOK standup 10 11","BOOK overlap 9 12","CONFLICTS 9 12","BOOK lunch 12 13","CONFLICTS 11 13"]return = ["true","true","false","focus,standup","true","lunch"]

focus and standup only touch, so both are accepted. overlap intersects them and is rejected. The first query returns accepted IDs in start order; the second reaches only lunch.

Example 2

operations = ["BOOK night 20 30","BOOK touch_left 10 20","BOOK touch_right 30 40","CONFLICTS 19 31","BOOK duplicate_start 20 21"]return = ["true","true","true","touch_left,night,touch_right","false"]

The first three bookings are disjoint under half-open boundaries even though they arrive out of start order. The wide query intersects all three. The final booking overlaps night and is rejected.

Example 3

operations = ["CONFLICTS 0 100","BOOK only 40 60","CONFLICTS 0 40","CONFLICTS 40 41"]return = ["","true","","only"]

The empty calendar and a query ending exactly where only starts produce empty strings. A query beginning at that boundary overlaps the booking.

Constraints

  • 1 <= operations.length <= 4000.
  • Every operation has one of the documented forms.
  • 0 <= start < end <= 10^9.
  • Booking IDs contain from 1 through 20 lowercase ASCII letters, digits, or underscores.
  • Every BOOK ID is unique across all attempts.

More LinkedIn problems

  • Explore an Unknown Grid and Find a PathONSITE INTERVIEW · Seen Nov 2026
  • Fire Station Response BillONSITE INTERVIEW · Seen Nov 2026
  • Sum an Arbitrary-Dimensional ArrayPHONE SCREEN · Seen Oct 2026
All LinkedIn interview questionsSee LinkedIn hiring insights
Saved
class Solution {
    public String[] scheduleTasks(String[] operations) {
        // Write your code here.
    }
}
Checking account…