#K71617. Maximize Binary Value
Maximize Binary Value
Maximize Binary Value
Given a binary string s, you are allowed to flip at most one bit from '0' to '1'. The objective is to create the maximum possible binary value.
Note that the significance of the digits is determined from left to right. Hence, flipping the leftmost '0' (if any) will yield the maximum possible number. If the string consists entirely of '1's, the string stays unchanged.
Formally, if we denote the binary string as \(s = s_0 s_1 \ldots s_{n-1}\), where \(s_0\) is the most significant bit, you should change the first occurrence of \(0\) into \(1\) if it exists. Otherwise, leave the string unchanged.
For example, given s = "1101"
, flipping the leftmost '0' results in "1111"
which is the maximum binary value obtainable with at most one bit flip.
inputFormat
The input consists of a single line containing the binary string s (\(1 \leq |s| \leq 10^5\)).
outputFormat
Output a single line containing the maximum binary string after flipping at most one bit.
## sample1101
1111