Skip to content

Practice Maximum Odd Binary Number

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

Easy#2864
LeetCode Problem

Maximum Odd Binary Number

Problem Statement

You are given a binary string s that contains at least one '1'. You have to rearrange the bits in such a way that the resulting binary number is the maximum odd binary number that can be created from this combination. Return a string representing the maximum odd binary number that can be created from the given combination. Note that the resulting string can have leading zeros.

Source: Maximum Odd Binary Number on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "010"
Output
"001"

# Example 2

Input
s = "0101"
Output
"1001"

Constraints

1 <= s.length <= 100
s consists only of '0' and '1'.
s contains at least one '1'.

Related LeetCode Problems

Practice more problems similar to Maximum Odd Binary Number.

Review your practice with PhantomCodeAI

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