英文链接:https://leetcode.com/problems/binary-watch/
中文链接:https://leetcode-cn.com/problems/binary-watch/
题目详述
二进制手表顶部有 4 个 LED 代表小时(0-11),底部的 6 个 LED 代表分钟(0-59)。
每个 LED 代表一个 0 或 1,最低位在右侧。
例如,上面的二进制手表读取 “3:25”。
给定一个非负整数 n 代表当前 LED 亮着的数量,返回所有可能的时间。
案例:
1 |
输入: n = 1 |
注意事项:
- 输出的顺序没有要求。
- 小时不会以零开头,比如 “01:00” 是不允许的,应为 “1:00”。
- 分钟必须由两位数组成,可能会以零开头,比如 “10:2” 是无效的,应为 “10:02”。
题目详解
枚举所有的状态空间,判断 1 的个数是否满足条件。
1 |
public class { |
近期评论