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)/二进制手表 [binary-watch].html

46 lines
1.4 KiB
HTML
Raw Normal View History

2022-03-27 20:56:26 +08:00
<p>二进制手表顶部有 4 个 LED 代表<strong> 小时0-11</strong>,底部的 6 个 LED 代表<strong> 分钟0-59</strong>。每个 LED 代表一个 0 或 1最低位在右侧。</p>
<ul>
2023-12-09 18:42:21 +08:00
<li>例如,下面的二进制手表读取 <code>"4:51"</code></li>
2022-03-27 20:56:26 +08:00
</ul>
2023-12-09 18:42:21 +08:00
<p><img src="https://assets.leetcode.com/uploads/2021/04/08/binarywatch.jpg" style="height: 300px; width" /></p>
2022-03-27 20:56:26 +08:00
<p>给你一个整数 <code>turnedOn</code> ,表示当前亮着的 LED 的数量,返回二进制手表可以表示的所有可能时间。你可以 <strong>按任意顺序</strong> 返回答案。</p>
<p>小时不会以零开头:</p>
<ul>
<li>例如,<code>"01:00"</code> 是无效的时间,正确的写法应该是 <code>"1:00"</code></li>
</ul>
<p>分钟必须由两位数组成,可能会以零开头:</p>
<ul>
<li>例如,<code>"10:2"</code> 是无效的时间,正确的写法应该是 <code>"10:02"</code></li>
</ul>
2023-12-09 18:42:21 +08:00
<p>&nbsp;</p>
2022-03-27 20:56:26 +08:00
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>turnedOn = 1
<strong>输出:</strong>["0:01","0:02","0:04","0:08","0:16","0:32","1:00","2:00","4:00","8:00"]
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>turnedOn = 9
<strong>输出:</strong>[]
</pre>
2023-12-09 18:42:21 +08:00
<p>&nbsp;</p>
2022-03-27 20:56:26 +08:00
<p><strong>提示:</strong></p>
<ul>
2023-12-09 18:42:21 +08:00
<li><code>0 &lt;= turnedOn &lt;= 10</code></li>
2022-03-27 20:56:26 +08:00
</ul>