You’re given a string s where each character represents a per-second event:
'E': one person enters and takes a chair,
'L': one person leaves, freeing a chair.
Starting from an empty room, return the minimum number of chairs required so that every entrant always finds a chair.
This equals the maximum number of people simultaneously inside at any time.
Input: s = "EEEEEEE"
Output: 7
Explanation:
Every second someone enters; peak occupancy = 7 → chairs = 7.
Input: s = "ELELEEL"
Output: 2
Explanation:
0: E → inside 1 (peak 1) 1: L → inside 0 2: E → inside 1 3: L → inside 0 4: E → inside 1 5: E → inside 2 (peak 2) 6: L → inside 1 Peak = 2 → chairs = 2.
Accepted:
Submission: