1405. Longest Happy String Medium
1/**
2 * [1405] Longest Happy String
3 *
4 * A string s is called happy if it satisfies the following conditions:
5 *
6 * s only contains the letters 'a', 'b', and 'c'.
7 * s does not contain any of "aaa", "bbb", or "ccc" as a substring.
8 * s contains at most a occurrences of the letter 'a'.
9 * s contains at most b occurrences of the letter 'b'.
10 * s contains at most c occurrences of the letter 'c'.
11 *
12 * Given three integers a, b, and c, return the longest possible happy string. If there are multiple longest happy strings, return any of them. If there is no such string, return the empty string "".
13 * A substring is a contiguous sequence of characters within a string.
14 *
15 * Example 1:
16 *
17 * Input: a = 1, b = 1, c = 7
18 * Output: "ccaccbcc"
19 * Explanation: "ccbccacc" would also be a correct answer.
20 *
21 * Example 2:
22 *
23 * Input: a = 7, b = 1, c = 0
24 * Output: "aabaa"
25 * Explanation: It is the only correct answer in this case.
26 *
27 *
28 * Constraints:
29 *
30 * 0 <= a, b, c <= 100
31 * a + b + c > 0
32 *
33 */
34pub struct Solution {}
35
36// problem: https://leetcode.com/problems/longest-happy-string/
37// discuss: https://leetcode.com/problems/longest-happy-string/discuss/?currentPage=1&orderBy=most_votes&query=
38
39// submission codes start here
40
41impl Solution {
42 pub fn longest_diverse_string(a: i32, b: i32, c: i32) -> String {
43 String::new()
44 }
45}
46
47// submission codes end
48
49#[cfg(test)]
50mod tests {
51 use super::*;
52
53 #[test]
54 fn test_1405() {
55 }
56}
57
Back
© 2025 bowen.ge All Rights Reserved.