Company: Rippling
Difficulty: medium
Binary String Operations Definitions A binary string consists of its actual digits. For example, 01011, 11111, and 00 are binary strings. The prefix of a string is any of its substrings that include the beginning of the string. For example, the prefixes of 110110 are 1, 11, 110, 1101, and 110110. A non-empty binary string is good if the following two conditions are true: The number of 1\'s is equal to the number of 0\'s For every prefix of the binary string, the number of 1\'s is not less than the number of 0\'s For example, 110110 is not good because it does not have an equal number of 0\'s and 1\'s, but 110010 is good because it satisfies both conditions. A good string can contain multiple good substrings. If two consecutive substrings are good, then they can be swapped as long as the resulting string is still a good string. Given a good binary string, you can perform zero or more swap operations on its adjacent good substrings such that the resulting string is the largest possible n