2864. Maximum Odd Binary Number Easy

@problem@discussion
#Math#String#Greedy



1/**
2 * [2864] Maximum Odd Binary Number
3 *
4 * You are given a binary string s that contains at least one '1'.
5 * 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.
6 * Return a string representing the maximum odd binary number that can be created from the given combination.
7 * Note that the resulting string can have leading zeros.
8 *  
9 * <strong class="example">Example 1:
10 * 
11 * Input: s = "010"
12 * Output: "001"
13 * Explanation: Because there is just one '1', it must be in the last position. So the answer is "001".
14 * 
15 * <strong class="example">Example 2:
16 * 
17 * Input: s = "0101"
18 * Output: "1001"
19 * Explanation: One of the '1's must be in the last position. The maximum number that can be made with the remaining digits is "100". So the answer is "1001".
20 * 
21 *  
22 * Constraints:
23 * 
24 * 	1 <= s.length <= 100
25 * 	s consists only of '0' and '1'.
26 * 	s contains at least one '1'.
27 * 
28 */
29pub struct Solution {}
30
31// problem: https://leetcode.com/problems/maximum-odd-binary-number/
32// discuss: https://leetcode.com/problems/maximum-odd-binary-number/discuss/?currentPage=1&orderBy=most_votes&query=
33
34// submission codes start here
35
36impl Solution {
37    pub fn maximum_odd_binary_number(s: String) -> String {
38        String::new()
39    }
40}
41
42// submission codes end
43
44#[cfg(test)]
45mod tests {
46    use super::*;
47
48    #[test]
49    fn test_2864() {
50    }
51}
52


Back
© 2025 bowen.ge All Rights Reserved.