Problem · Array

Chairs Requirement

Learn this problem
EasyAtlassian logoAtlassianINTERNFULLTIMEOA

Problem statement

For each simulation, determine the minimum chairs that must be purchased. C is an arrival to the workroom, R leaves for a meeting, U returns from a meeting, and L leaves work. An arrival or return uses an available chair or purchases one; a meeting departure or final departure frees one.

Function

minChairs(simulations: String[]) → int[]

Examples

Example 1

simulations = ["CCRUCL","CRUC","CCCC"]return = [3,2,4]

Tracking the available pool independently for each simulation gives the three purchase totals.

Constraints

  • 1 <= simulations.length <= 100
  • 1 <= simulations[i].length <= 10000
  • Every simulation is a valid sequence over C,R,U,L.

More Atlassian problems

drafts saved locally
public int[] minChairs(String[] simulations) {
  // Write your code here.
}
simulations["CCRUCL","CRUC","CCCC"]
expected[3,2,4]
checking account