FastPrepProcess Scheduling
Problems/Process Scheduling

Process Scheduling

Citadel logoCitadel● EasyOA
QuestionFunctionExamples

Problem statement

Grace Hopper is famously recognized as the "First Lady of Software." She played a significant role in the creation of the first all-electrical digital computer, UNIVAC (Universal Automatic Computer).

Hopper's responsibilities included developing a process synchronization solution to ensure that never-ending processes experience a bounded wait, i.e., one that never completes. She designed an algorithm where one process cannot occupy consecutive time slots.

To evaluate the performance of this algorithm, Hopper needed to determine the number of ways to allocate n_processes in n_intervals different time intervals according to the algorithm. Since the number of ways can be very large, return the result modulo 10^9 + 7.

Note: All the processes are never-ending, so even if n_intervals is very large, the processes will not end.

Function

processScheduling(n_intervals: int, n_processes: int) → int

Complete the function processScheduling in the editor with the following parameters:

  • n_intervals: the number of time intervals
  • n_processes: the number of processes

Returns int: the number of ways processes can be scheduled in time intervals modulo 10^9 + 7

Examples

Example 1

n_intervals = 3n_processes = 2return = 2

The source example shows the schedule allocation can look like {A, B, A} or {B, A, B}. These are the two valid allocations for the given inputs, so the answer is 2.

More Citadel problems

  • Portfolio Tickers with Constant-Time Random PickPHONE SCREEN · Seen Nov 2026
  • Square Root FunctionPHONE SCREEN · Seen Oct 2026
  • Reachable Transfer PositionsPHONE SCREEN · Seen Oct 2026
All Citadel interview questionsSee Citadel hiring insights
Saved
public int processScheduling(int n_intervals, int n_processes) {
  // write your code here
}
Checking account…