Minimum number of chairs required to ensure that every worker is seated at any instant | C # program to implement the above approach ; Function to find the minimum number of chairs required to ensure that every worker is seated at any time ; Stores the number of chairs required ; Pointer to iterate ; Stores minimum number of chairs required ; Iterate over every character ; If character is ' E ' ; Increase the count ; Otherwise ; Update maximum value of count obtained at any given time ; Return mini ; Driver code ; Given String ; Function call to find the minimum number of chairs
using System ; using System . Collections . Generic ; class GFG { static int findMinimumChairs ( string s ) { int count = 0 ; int i = 0 ; int mini = Int32 . MinValue ; while ( i < s . Length ) { if ( s [ i ] == ' E ' ) count ++ ; else count -- ; mini = Math . Max ( count , mini ) ; i ++ ; } return mini ; } public static void Main ( ) { string s = " EELEE " ; Console . WriteLine ( findMinimumChairs ( s ) ) ; } }