Skip to content

Practice Maximum Binary String After Change

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#1702
LeetCode Problem

Maximum Binary String After Change

Problem Statement

Apply either replacement to any occurrence as often as desired: 00 becomes 10, or 10 becomes 01. Return the numerically greatest binary string reachable from binary; each replacement preserves the string length.

Source: Maximum Binary String After Change on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
binary = "000110"
Output
"111011"

# Example 2

Input
binary = "01"
Output
"01"

Constraints

1 <= binary.length <= 10^5
binary consist of '0' and '1'.

Related LeetCode Problems

Practice more problems similar to Maximum Binary String After Change.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.