Minimum Number of Chairs in a Waiting Room

As a Systems Engineer at Tata Consultancy Services, I deliver exceptional software products for mobile and web platforms, using agile methodologies and robust quality maintenance. I am experienced in performance testing, automation testing, API testing, and manual testing, with various tools and technologies such as Jmeter, Azure LoadTest, Selenium, Java, OOPS, Maven, TestNG, and Postman.
I have successfully developed and executed detailed test plans, test cases, and scripts for Android and web applications, ensuring high-quality standards and user satisfaction. I have also demonstrated my proficiency in manual REST API testing with Postman, as well as in end-to-end performance and automation testing using Jmeter and selenium with Java, TestNG and Maven. Additionally, I have utilized Azure DevOps for bug tracking and issue management.
You are given a string s. Simulate events at each second i:
If
s[i] == 'E', a person enters the waiting room and takes one of the chairs in it.If
s[i] == 'L', a person leaves the waiting room, freeing up a chair.
Return the minimum number of chairs needed so that a chair is available for every person who enters the waiting room given that it is initially empty.
LeetCode Problem - 3168
class Solution {
public int minimumChairs(String s) {
// Initialize variables to keep track of the current count and the maximum count needed
int count = 0, answer = 0;
// Iterate through each character in the input string
for(char c : s.toCharArray()) {
// Increment count for 'E' (entry) and decrement for any other character (assumed 'L' for leave)
if(c == 'E') count++;
else count--;
// Update the answer with the maximum value between the current count and the current answer
answer = Math.max(count, answer);
}
// Return the maximum number of chairs needed at any point in time
return answer;
}
}




