Description
A binary watch has 4 LEDs for hours (0-11) and 6 LEDs for minutes (0-59). Given turnedOn (number of LEDs on), return all possible times in "h:mm" format.
Examples
Input:
turnedOn = 1Output:
["0:01","0:02","0:04","0:08","0:16","0:32","1:00","2:00","4:00","8:00"]Explanation:
One LED on.
Input:
turnedOn = 9Output:
[]Explanation:
A binary watch has 10 LEDs (4 for hours, 6 for minutes). Having 9 LEDs on is impossible since the maximum valid time is 11:59, which uses fewer bits.
Input:
turnedOn = 2Output:
["0:03","0:05","0:06","0:09","0:10","0:12","0:17","0:18","0:20","0:24","0:33","0:34","0:36","0:40","0:48","1:01","1:02","1:04","1:08","1:16","1:32","2:01","2:02","2:04","2:08","2:16","2:32","3:00","4:01","4:02","4:04","4:08","4:16","4:32","5:00","6:00","8:01","8:02","8:04","8:08","8:16","8:32","9:00","10:00"]Explanation:
Two LEDs on. The valid times are those where exactly 2 bits are set to 1 across the hour (4 bits) and minute (6 bits) representations. For example, '0:03' has minutes=3 (binary 000011, 2 bits), '1:01' has hour=1 (binary 0001, 1 bit) and minutes=1 (binary 000001, 1 bit).
Constraints
- •
0 ≤ turnedOn ≤ 10