Schedule Tasks with an Interval Tree
Reported by candidates from LinkedIn's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The mistake that sinks a first attempt on this LinkedIn OA, reported September 2026, is treating touching intervals as overlaps. Half-open [start, end) means 9-10 and 10-11 coexist fine. The task is a calendar with BOOK and CONFLICTS operations, and it's tagged as a tree problem. Up to 4000 operations, times up to 10^9. If you blank on the boundary logic during the live assessment, StealthCoder runs invisibly on your desktop and hands you a working solution. Know the trick first, though. It's short.
The problem
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.
Reported by candidates. Source: FastPrep
Pattern and pitfall
Accepted bookings are always pairwise disjoint. That's the whole trick. Keep them sorted by start, and a new interval can only collide with its predecessor or successor in that order. Find the insertion point with binary search or a balanced tree, then check prev.end > start and next.start < end. For CONFLICTS, binary search to the first booking that could overlap, then walk right while booking.start < queryEnd, collecting IDs. Since the list is disjoint and sorted by start, it's also sorted by end, so the walk is clean. The common pitfall is using <= instead of <, which breaks the touching cases in Example 2. Another is forgetting that rejected bookings must not be stored. With 4000 operations, even a sorted array with insertion passes, so don't overbuild a real interval tree. StealthCoder is the hedge if the boundary math slips under pressure in the live OA.
The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.
You can drill Schedule Tasks with an Interval Tree cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass LinkedIn's OA.
LinkedIn reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Schedule Tasks with an Interval Tree FAQ
What's the trick in the LinkedIn interval scheduling OA?+
Accepted bookings never overlap, so keep them sorted by start. A new booking only needs a check against its neighbors. Binary search for the position, compare with the previous end and next start, and insert if both are clear.
Do I really need an interval tree?+
No. With at most 4000 operations, a sorted list with binary search and insertion is fast enough. A balanced tree or ordered map gives better worst case, but the simpler structure is less error-prone under time pressure.
How do half-open intervals change the overlap check?+
Two intervals overlap only when leftStart < rightEnd and rightStart < leftEnd. Strict inequalities mean that an interval ending at 10 and another starting at 10 don't conflict. Using <= is the classic bug.
How should CONFLICTS output be ordered and formatted?+
Order IDs by booking start, joined with commas and no spaces. Return an empty string when nothing overlaps. Because accepted bookings are disjoint and sorted, a left-to-right scan from the first possible overlap gives the right order.
How do I prepare for this in 48 hours?+
Write the sorted-list solution once with bisect or a TreeMap. Test the three examples by hand, especially touching boundaries and out-of-order arrivals. Then test a query that spans everything. That covers nearly every failure mode here.