761. Special Binary String Hard

@problem@discussion
#String#Recursion



1/**
2 * [761] Special Binary String
3 *
4 * Special binary strings are binary strings with the following two properties:
5 * 
6 * 	The number of 0's is equal to the number of 1's.
7 * 	Every prefix of the binary string has at least as many 1's as 0's.
8 * 
9 * You are given a special binary string s.
10 * A move consists of choosing two consecutive, non-empty, special substrings of s, and swapping them. Two strings are consecutive if the last character of the first string is exactly one index before the first character of the second string.
11 * Return the lexicographically largest resulting string possible after applying the mentioned operations on the string.
12 *  
13 * Example 1:
14 * 
15 * Input: s = "11011000"
16 * Output: "11100100"
17 * Explanation: The strings "10" [occuring at s[1]] and "1100" [at s[3]] are swapped.
18 * This is the lexicographically largest string possible after some number of swaps.
19 * 
20 * Example 2:
21 * 
22 * Input: s = "10"
23 * Output: "10"
24 * 
25 *  
26 * Constraints:
27 * 
28 * 	1 <= s.length <= 50
29 * 	s[i] is either '0' or '1'.
30 * 	s is a special binary string.
31 * 
32 */
33pub struct Solution {}
34
35// problem: https://leetcode.com/problems/special-binary-string/
36// discuss: https://leetcode.com/problems/special-binary-string/discuss/?currentPage=1&orderBy=most_votes&query=
37
38// submission codes start here
39
40impl Solution {
41    pub fn make_largest_special(s: String) -> String {
42        String::new()
43    }
44}
45
46// submission codes end
47
48#[cfg(test)]
49mod tests {
50    use super::*;
51
52    #[test]
53    fn test_761() {
54    }
55}
56


Back
© 2025 bowen.ge All Rights Reserved.