Help Needed for PayPal Coding Test Question
Anonymous User
757

This question was asked in an online test. I have no clue how to get started with it even now. Could someone help please?
How to aproach the question and the code

Given a binary String 0 denotes a person in red uniform and 1 denotes a person in blue uniform. The goal is to removeany occurrence of "01" in the binary string. More formally at each second all the substrings "01" in the string s are 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 s = "001011

t = 1 : 010101
t = 2: 101010
t = 3: 110100
t = 4: 111000

Hence above process takes 4 seconds
Comments (7)