984. String Without AAA or BBB Medium
1/**
2 * [984] String Without AAA or BBB
3 *
4 * Given two integers a and b, return any string s such that:
5 *
6 * s has length a + b and contains exactly a 'a' letters, and exactly b 'b' letters,
7 * The substring 'aaa' does not occur in s, and
8 * The substring 'bbb' does not occur in s.
9 *
10 *
11 * Example 1:
12 *
13 * Input: a = 1, b = 2
14 * Output: "abb"
15 * Explanation: "abb", "bab" and "bba" are all correct answers.
16 *
17 * Example 2:
18 *
19 * Input: a = 4, b = 1
20 * Output: "aabaa"
21 *
22 *
23 * Constraints:
24 *
25 * 0 <= a, b <= 100
26 * It is guaranteed such an s exists for the given a and b.
27 *
28 */
29pub struct Solution {}
30
31// problem: https://leetcode.com/problems/string-without-aaa-or-bbb/
32// discuss: https://leetcode.com/problems/string-without-aaa-or-bbb/discuss/?currentPage=1&orderBy=most_votes&query=
33
34// submission codes start here
35
36impl Solution {
37 pub fn str_without3a3b(a: i32, b: i32) -> 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_984() {
50 }
51}
52
Back
© 2025 bowen.ge All Rights Reserved.