1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/最长快乐字符串 [longest-happy-string].html
2022-03-29 12:43:11 +08:00

42 lines
1.6 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>如果字符串中不含有任何 <code>&#39;aaa&#39;</code><code>&#39;bbb&#39;</code><code>&#39;ccc&#39;</code> 这样的字符串作为子串,那么该字符串就是一个「快乐字符串」。</p>
<p>给你三个整数 <code>a</code><code>b</code> <code>c</code>,请你返回 <strong>任意一个</strong> 满足下列全部条件的字符串 <code>s</code></p>
<ul>
<li><code>s</code> 是一个尽可能长的快乐字符串。</li>
<li><code>s</code><strong>最多</strong><code>a</code> 个字母 <code>&#39;a&#39;</code><code>b</code>&nbsp;个字母 <code>&#39;b&#39;</code><code>c</code> 个字母 <code>&#39;c&#39;</code></li>
<li><code>s </code>中只含有 <code>&#39;a&#39;</code><code>&#39;b&#39;</code><code>&#39;c&#39;</code> 三种字母。</li>
</ul>
<p>如果不存在这样的字符串 <code>s</code> ,请返回一个空字符串 <code>&quot;&quot;</code></p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre><strong>输入:</strong>a = 1, b = 1, c = 7
<strong>输出:</strong>&quot;ccaccbcc&quot;
<strong>解释:</strong>&quot;ccbccacc&quot; 也是一种正确答案。
</pre>
<p><strong>示例 2</strong></p>
<pre><strong>输入:</strong>a = 2, b = 2, c = 1
<strong>输出:</strong>&quot;aabbc&quot;
</pre>
<p><strong>示例 3</strong></p>
<pre><strong>输入:</strong>a = 7, b = 1, c = 0
<strong>输出:</strong>&quot;aabaa&quot;
<strong>解释:</strong>这是该测试用例的唯一正确答案。</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>0 &lt;= a, b, c &lt;= 100</code></li>
<li><code>a + b + c &gt; 0</code></li>
</ul>