#401
Binary Watch
pupil · 405 · lc easy +24 · verified · 65.2% accepted · 1,956 likes · top 69%
Description
A binary watch has 4 LEDs encoding hours (0–11) and 6 LEDs encoding minutes (0–59) in binary, with the least significant bit on the right.
Given turnedOn (the number of LEDs currently illuminated), enumerate every valid time the watch could be displaying. Return the results in any order.
Formatting: hours omit leading zeros ("1:00" not "01:00"); minutes always use exactly two digits ("10:02" not "10:2").
Example 1:
Input: turnedOn = 1
Output: ["0:01","0:02","0:04","0:08","0:16","0:32","1:00","2:00","4:00","8:00"]
Example 2:
Input: turnedOn = 9
Output: []
Code
1
2
3