As reported: PayPal iOS engineer, Karat technical screen (2025), first of two coding questions: given staff availability and time slots, find the understaffed time periods and return them.
You are given:
availability— one entry[start, end]per staff member: that person is available fromstart(inclusive) toend(exclusive).slots— entries[start, end, required]: the slot fromstarttoendneeds at leastrequiredpeople.
A staff member covers a slot if they are available for the whole slot (personStart ≤ slotStart and slotEnd ≤ personEnd). Return the slots covered by fewer than required people, as [start, end] pairs, in the order they appear in slots.
Example 1
availability = [[9,17],[12,20],[8,12]]
slots = [[8,9,1],[9,12,2],[12,17,2],[17,20,2]]
-> [[17,20]]
[17,20] is covered only by the person available [12,20]; it needs two.
Example 2
availability = [[0,24]]
slots = [[0,24,1],[5,6,2]]
-> [[5,6]]
Constraints: 0 ≤ availability.length, slots.length ≤ 1000; times are integers in [0, 2000] with start < end; 0 ≤ required ≤ 1000.
Code runner format: one JSON value per line: availability, then slots. The harness prints the list of understaffed slots.
Clarifications
- A person available
[9,12]does not cover a slot[9,13]— partial coverage does not count. - A slot with
required = 0is never understaffed.