Tap here to switch tabs
Problem
Submissions

Problem: Maximum Binary String After Change

med
30 min
Try to solve the Maximum Binary String After Change problem.

Statement

You are given a binary string binary consisting of characters '$0$' and '$1$'.

You may apply either of the following operations on binary any number of times:

  • Change any substring "0000" to "1010"

  • Change any substring "1010" to "0101"

Return the maximum binary string that can be formed after applying any number of operations. A binary string is considered larger than another if its base 22 value is greater.

Constraints:

  • 1≤1 \leq binary.length ≤105\leq 10^5

  • binary consists only of '$0$' and '$1$'.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Binary String After Change

med
30 min
Try to solve the Maximum Binary String After Change problem.

Statement

You are given a binary string binary consisting of characters '$0$' and '$1$'.

You may apply either of the following operations on binary any number of times:

  • Change any substring "0000" to "1010"

  • Change any substring "1010" to "0101"

Return the maximum binary string that can be formed after applying any number of operations. A binary string is considered larger than another if its base 22 value is greater.

Constraints:

  • 1≤1 \leq binary.length ≤105\leq 10^5

  • binary consists only of '$0$' and '$1$'.