Problem · Simulation
Chairs Requirement
Learn this problemProblem statement
In this challenge, determine the minimum number of chairs to be purchased to accommodate all workers in a new business workroom. There is no chair at the beginning.
There will be a string array of simulations. Each simulation is described by a combination of four characters: C, R, U, and L
C- A new employee arrives in the workroom. If there is a chair available, the employee takes it. Otherwise, a new one is purchased.R- An employee goes to a meeting room, freeing up a chair.U- An employee arrives from a meeting room. If there is a chair available, the employee takes it. Otherwise, a new one is purchased.L- An employee leaves the workroom, freeing up a chair.
Function
minChair(simulation: String[]) → int[]
Complete the minChair function.
minChair has the following parameter(s):
string simulation[n]: an array of strings representing discrete simulations to process.
Return
int[n]: an array of integers denoting the minimal number of chairs required for each simulation.
Examples
Example 1
simulation = ["CRUL"]return = [1]
In this case, there is only one simulation, At first, there are 0 chairs.
The minimum number of chairs to be purchased in one chair in this case. Result = [1].
CRUL, represented in the table above.
"C": A new employee arrives in the workroom and one chair was purchased."R": An employee goes to the meeting room, freeing up a chair."U": An employee arrives from the meeting room, took the chair available."L": An employee leaves the workroom, freeing up a chair.Constraints
1 ≤ n ≤ 1001 ≤ length of each simulation[i] ≤ 10000More Goldman Sachs problems
- Data ReorganizationSeen Jul 2026
- Inherited Role PermissionsONSITE INTERVIEW · Seen Jul 2026
- Root of the Largest TreePHONE SCREEN · Seen Jul 2026
- Validate Binary Search TreeONSITE INTERVIEW · Seen Jul 2026
- Alternating Parity PermutationsOA · Seen Jul 2026
- Threshold AlertsSeen Jul 2026
- Cheapest Flights Within K StopsONSITE INTERVIEW · Seen Jun 2026
- Word LadderPHONE SCREEN · Seen Jun 2026