1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-10-12 17:05:15 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
Files
leetcode-problemset/leetcode-cn/problem (Chinese)/Fizz Buzz [fizz-buzz].html
2025-09-29 14:43:44 +08:00

39 lines
1.1 KiB
HTML
Raw Permalink 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>n</code> ,返回一个字符串数组 <code>answer</code><strong>下标从 1 开始</strong>),其中:</p>
<ul>
<li><code>answer[i] == "FizzBuzz"</code> 如果 <code>i</code> 同时是 <code>3</code><code>5</code> 的倍数。</li>
<li><code>answer[i] == "Fizz"</code> 如果 <code>i</code><code>3</code> 的倍数。</li>
<li><code>answer[i] == "Buzz"</code> 如果 <code>i</code><code>5</code> 的倍数。</li>
<li><code>answer[i] == i</code> (以字符串形式)如果上述条件全不满足。</li>
</ul>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>n = 3
<strong>输出:</strong>["1","2","Fizz"]
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>n = 5
<strong>输出:</strong>["1","2","Fizz","4","Buzz"]
</pre>
<p><strong>示例 3</strong></p>
<pre>
<strong>输入:</strong>n = 15
<strong>输出:</strong>["1","2","Fizz","4","Buzz","Fizz","7","8","Fizz","Buzz","11","Fizz","13","14","FizzBuzz"]</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= n &lt;= 10<sup>4</sup></code></li>
</ul>