Skip to content

Commit 210a81b

Browse files
authored
Create Minimum Number of Chairs in a Waiting Room.java
1 parent b4ddaff commit 210a81b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution {
2+
public int minimumChairs(String s) {
3+
int requiredChairCount = 0;
4+
int currChairCount = 0;
5+
for (char c : s.toCharArray()) {
6+
currChairCount += c == 'E' ? 1 : -1;
7+
requiredChairCount = Math.max(requiredChairCount, currChairCount);
8+
}
9+
return requiredChairCount;
10+
}
11+
}

0 commit comments

Comments
 (0)