1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/Fizz Buzz [fizz-buzz].html

39 lines
1.2 KiB
HTML
Raw Normal View History

2022-03-27 20:56:26 +08:00
<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>