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)/Fizz Buzz [fizz-buzz].html
2022-03-29 12:43:11 +08:00

39 lines
1.2 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>n</code> ,找出从 <code>1</code><code>n</code> 各个整数的 Fizz Buzz 表示,并用字符串数组 <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>