Tap here to switch tabs
Problem
Submissions

Problem: Minimum Number of Chairs in a Waiting Room

Minimum Number of Chairs in a Waiting Room gives a valid event string of entries and exits. Return the fewest chairs needed to seat everyone throughout the sequence.

Statement

You are given a string s representing a sequence of events occurring in a waiting room at each second.

Each character in s describes an event:

  • 'E' indicates that a person enters the waiting room and takes a chair.

  • 'L' indicates that a person leaves the waiting room and vacates a chair.

At any time, the waiting room must have enough chairs to accommodate every person currently present. Return the minimum number of chairs required so that there is always an available chair for each person entering the room.

Constraints:

  • 1≤1 \leq s.length ≤50\leq 50

  • s consists only of the letters 'E' and 'L'.

  • s represents a valid sequence of entries and exits.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Number of Chairs in a Waiting Room

Minimum Number of Chairs in a Waiting Room gives a valid event string of entries and exits. Return the fewest chairs needed to seat everyone throughout the sequence.

Statement

You are given a string s representing a sequence of events occurring in a waiting room at each second.

Each character in s describes an event:

  • 'E' indicates that a person enters the waiting room and takes a chair.

  • 'L' indicates that a person leaves the waiting room and vacates a chair.

At any time, the waiting room must have enough chairs to accommodate every person currently present. Return the minimum number of chairs required so that there is always an available chair for each person entering the room.

Constraints:

  • 1≤1 \leq s.length ≤50\leq 50

  • s consists only of the letters 'E' and 'L'.

  • s represents a valid sequence of entries and exits.