
- 2 Parade In Hackerland The People In Hackerland Are Getting Ready For A Parade And The Participants Are All Mixed Up 1 (210.47 KiB) Viewed 311 times

- 2 Parade In Hackerland The People In Hackerland Are Getting Ready For A Parade And The Participants Are All Mixed Up 2 (156.72 KiB) Viewed 311 times

- 2 Parade In Hackerland The People In Hackerland Are Getting Ready For A Parade And The Participants Are All Mixed Up 3 (158.08 KiB) Viewed 311 times

- 2 Parade In Hackerland The People In Hackerland Are Getting Ready For A Parade And The Participants Are All Mixed Up 4 (164.57 KiB) Viewed 311 times

- 2 Parade In Hackerland The People In Hackerland Are Getting Ready For A Parade And The Participants Are All Mixed Up 5 (142.08 KiB) Viewed 311 times
2. Parade in HackerLand The people in HackerLand, are getting ready for a parade, and the participants are all mixed up. There should be no instance where a red uniform is immediately to the left of a blue one. Given a binary string, 0 denotes a person in red uniform and 1 denotes a person in blue uniform. The goal is to remove any occurrence of "01" in the binary string. More formally, at each second, all the substrings "01" in the string sare changed to "10". This process repeats until no "01" is present in the string. All the substrings "01" in the current state of s are changed at the same time. Find the number of seconds it takes for this process to stop. Example color= "001011"
Example color="001011" Here is a simulation of the process where t denotes the current time. t=0, color= "001011" t=1, color="010101" t=2, color="101010" t=3, color="110100" t=4, color="111000" Hence this process takes 4 seconds. Function Description Complete the function getSwapTime in the editor below.
getSwap Time has the following parameter(s): string color: a binary string that represents the uniform colors of people Returns int: the time to complete the process Constraints • 1 ≤ /color/ ≤ 3*105 where /color] denotes the size of the binary string ► Input Format for Custom Testing ✓ Sample Case 0 Sample Input 0
► Input Format for Custom Testing ▾ Sample Case 0 Sample Input 0 STDIN FUNCTION 0101 color = '0101' Sample Output 0 2 Explanation t = 0, s= "0101" t=1,s="1010" t=2, s= "1100" ✓ Sample Case 1 Sample Input 1 STDIN 1111 FUNCTION color = '1111'
STDIN 0101 Sample Output 0 2 Explanation t=0, s= "0101" t=1,s="1010" t=2,s="1100" ▾ Sample Case 1 Sample Input 1 STDIN 1111 Sample Output 1 0 Explanation There are no substrings "01" FUNCTION color = '0101' FUNCTION color = '1111'