Home / Expert Answers / Computer Science / in-this-challenge-determine-the-minimum-number-of-chairs-to-be-purchased-to-accommodate-all-worker-pa719

(Solved): In this challenge, determine the minimum number of chairs to be purchased to accommodate all worker ...




In this challenge, determine the minimum number of chairs to be purchased to accommodate all workers in a new business workro
In this case, there is only one simulation, CRUL, represented in the table below:
- At first, there are 0 chairs.
- C: A ne
Function Description
Complete the minChairsfunction in the editor below.
minChairs has the following parameter(s):
string sim
Sample linput 0
Explanation
For \( { }^{\text {st }} \) simulation: CCRUCL
\begin{tabular}{|l|l|l|}
\hline Action & Total & A
In this challenge, determine the minimum number of chairs to be purchased to accommodate all workers in a new business workroom. The meeting room is not under consideration and 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: \( \mathrm{C}, \mathrm{R}, \mathrm{U} \), and \( \mathrm{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 the meeting room, freeing up a chair. - U-An employee arrives from the 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. Example Given an array of strings representing the simulations \( a=[ \) "CRUL"] In this case, there is only one simulation, CRUL, represented in the table below: In this case, there is only one simulation, CRUL, represented in the table below: - At first, there are 0 chairs. - "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. The minimum number of chairs to be purchased is one chair in this case. result=[1] Function Description Complete the minChairs function in the editor below. Function Description Complete the minChairsfunction in the editor below. minChairs has the following parameter(s): string simulations[n]: an array of strings representing discrete simulations to process. Returns: int[n]: an array of integers denoting the minimal number of chairs required for each simulation. Constraints - \( 1 \leq n \leq 100 \) - 1 slength of each simulations[1] \( \leq 10000 \) Input Format For Custom Testing Sample Case 0 Sample Input 0 \( \begin{array}{ll}\text { STDIN } & \text { Function } \\ \hdashline & \rightarrow \quad \text { simulationsII size } n=3\end{array} \) Sample linput 0 Explanation For \( { }^{\text {st }} \) simulation: CCRUCL \begin{tabular}{|l|l|l|} \hline Action & Total & Available \\ \hline\( - \) & 0 & 0 \\ \hline C & 1 & 0 \\ \hline C & 2 & 0 \\ \hline R & 2 & 1 \\ \hline \end{tabular}


We have an Answer from Expert

View Expert Answer

Expert Answer


We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe