FastPrepInterview Slot Booking
Problems/Interview Slot Booking

Interview Slot Booking

TrueFoundry logoTrueFoundry● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The interviewer asked you to define the database schema and write the code for three APIs, for interviewers, their availability, and interviews. MarkSlots lets interviewers mark the free hours when they can do interviews. GetAvailableSlots gives candidates a list of all open time slots for interviews within the next 14 days. BookInterview lets a candidate book an interview by picking a time slot, and the system assigns an available interviewer automatically.

The report does not say how long a slot is, which free interviewer gets a booking, what the 14 days count from, or how time zones work. Here, slots are one hour on whole hours in one time zone, the free interviewer with the smallest ID gets the booking, and the 14 days start at the hour you are given. You get the API calls as a list of operations that return numbers, without the database tables, candidate names, or JSON messages.

Our version is about 70% the same as the reported question.

Build the core of an interview scheduling service. Interviewers mark the hours when they are free, candidates list the open slots for the next 14 days, and candidates book a slot, which is given to a free interviewer automatically.

Time is counted in whole hours, all in the same time zone. A slot is one hour of one interviewer: slot h runs from hour h to hour h + 1. Process the operations in operations in order. For each index i, args[i] holds the arguments of operations[i].

  • "markSlots" with args[i] = [interviewerId, startHour, endHour]: the interviewer is free for every slot h with startHour <= h < endHour. Marking a slot that was already marked changes nothing, even if that slot has been booked. This records nothing.
  • "getAvailableSlots" with args[i] = [now]: record every free slot h of every interviewer with now <= h < now + 336 (the next 14 days). List them by increasing hour, and by increasing interviewer ID within the same hour. Record them as one flat row [hour1, interviewerId1, hour2, interviewerId2, ...], which is empty when there are none.
  • "bookInterview" with args[i] = [hour]: a candidate books slot hour. Among the interviewers who are free at that hour, the one with the smallest ID gets the interview, so that slot is no longer free. Record [interviewerId] for the chosen interviewer, or [-1] if no interviewer is free at that hour.

Return the recorded rows of all "getAvailableSlots" and "bookInterview" operations, in order.

Function

runInterviewScheduler(operations: String[], args: int[][]) → int[][]

Examples

Example 1

operations = ["markSlots","markSlots","getAvailableSlots","bookInterview","getAvailableSlots"]args = [[123,11,14],[456,11,12],[0],[11],[0]]return = [[11,123,11,456,12,123,13,123],[123],[11,456,12,123,13,123]]

Interviewer 123 is free for slots 11, 12, and 13. Interviewer 456 is free for slot 11.

The first "getAvailableSlots" lists all four slots: hour 11 with interviewers 123 and 456, then hours 12 and 13 with 123.

The booking for hour 11 goes to 123, the smaller free ID. The second listing no longer has slot 11 of interviewer 123.

Example 2

operations = ["markSlots","bookInterview","bookInterview","markSlots","bookInterview","getAvailableSlots"]args = [[7,100,102],[100],[100],[7,100,101],[101],[100]]return = [[7],[-1],[7],[]]

Interviewer 7 is free for slots 100 and 101. The first booking for hour 100 goes to 7. The second booking for hour 100 finds nobody free, so it records [-1].

Marking slot 100 again changes nothing, because that slot was already marked and is now booked. The booking for hour 101 goes to 7. After that, no slot is free, so the listing is empty.

Example 3

operations = ["markSlots","markSlots","getAvailableSlots","getAvailableSlots"]args = [[2,335,337],[1,0,1],[0],[1]]return = [[0,1,335,2],[335,2,336,2]]

With now = 0, the window holds hours 0 through 335. It includes slot 0 of interviewer 1 and slot 335 of interviewer 2, but not slot 336.

With now = 1, the window holds hours 1 through 336, so it has slots 335 and 336 of interviewer 2 and no longer has slot 0.

Constraints

  • 1 <= operations.length <= 2000
  • args.length == operations.length
  • Each operations[i] is "markSlots", "getAvailableSlots", or "bookInterview".
  • For "markSlots", args[i] = [interviewerId, startHour, endHour] with 1 <= interviewerId <= 1000, 0 <= startHour < endHour <= 10^6, and endHour - startHour <= 48.
  • For "getAvailableSlots", args[i] = [now] with 0 <= now <= 10^6.
  • For "bookInterview", args[i] = [hour] with 0 <= hour <= 10^6.

More TrueFoundry Phone Screen questions

  • Verify Words Sorted by a Custom AlphabetPHONE SCREEN · Seen Jul 2026
  • Versioned ArrayPHONE SCREEN · Seen Jul 2026

Similar questions at other companies

  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • Camel CardsRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
  • Structured Log Stream with QueriesOpenAI · PHONE SCREENOpenAI interview questions
  • Banking System with Pending Transfer AcceptanceCircle · PHONE SCREENCircle interview questions
  • Streaming Top-K Frequent ElementsNVIDIA · PHONE SCREENNVIDIA interview questions
  • Document Enrichment Stream AggregatorBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • In-Memory Database with TTL and Historical QueriesZip · PHONE SCREENZip interview questions
  • Subscription and Usage-Based Billing CalculatorStripe · OAStripe interview questions
  • Banking System with Top ActivityCapital One · ONSITE INTERVIEWCapital One interview questions
  • Temporal Key-Field Database with Prefix ScansThe Trade Desk · OA
See TrueFoundry hiring insights
Saved
class Solution {
    public int[][] runInterviewScheduler(String[] operations, int[][] args) {
        // Write your solution here.
    }
}
Checking account…