Binary Watch

A binary watch has 4 LEDs for the hour (0-11) and 6 LEDs for the minute (0-59), each LED one bit. Given `turnedOn`, the number of LEDs that are on, return every time the watch could show, in any order. The hour has no leading zero ("1:00", not "01:00") and the minute always has two digits ("10:02", not "10:2").

30:00

Binary Watch
easy
Free written solution
Topics
Companies

A binary watch has 4 LEDs for the hour (0-11) and 6 LEDs for the minute (0-59), each LED one bit. Given turnedOn, the number of LEDs that are on, return every time the watch could show, in any order. The hour has no leading zero ("1:00", not "01:00") and the minute always has 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"]
Constraints:
  • 0≤turnedOn≤100 \leq \text{turnedOn} \leq 10

Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result

Run code to see results.

Input
arr ={"turnedOn":1}

Only 12 x 60 = 720 times exist, so check each one: a time works when its hour bits plus its minute bits add up to 1.

-:--

HOUR

8

4

2

1

MIN

32

16

8

4

2

1

LED budget: turnedOn = 1

times found (0)

none yet

Variables
VariableValue
turnedOn1
hnull
mnull
found0
DepthFunction Call
Stack empty
0/18