767. Reorganize String Medium

@problem@discussion
#Hash Table#String#Greedy#Sorting#Heap (Priority Queue)#Counting



1/**
2 * [767] Reorganize String
3 *
4 * Given a string s, rearrange the characters of s so that any two adjacent characters are not the same.
5 * Return any possible rearrangement of s or return "" if not possible.
6 *  
7 * Example 1:
8 * Input: s = "aab"
9 * Output: "aba"
10 * Example 2:
11 * Input: s = "aaab"
12 * Output: ""
13 *  
14 * Constraints:
15 * 
16 * 	1 <= s.length <= 500
17 * 	s consists of lowercase English letters.
18 * 
19 */
20pub struct Solution {}
21
22// problem: https://leetcode.com/problems/reorganize-string/
23// discuss: https://leetcode.com/problems/reorganize-string/discuss/?currentPage=1&orderBy=most_votes&query=
24
25// submission codes start here
26
27impl Solution {
28    pub fn reorganize_string(s: String) -> String {
29        String::new()
30    }
31}
32
33// submission codes end
34
35#[cfg(test)]
36mod tests {
37    use super::*;
38
39    #[test]
40    fn test_767() {
41    }
42}
43


Back
© 2025 bowen.ge All Rights Reserved.