Skip to content

Binary Watch

EasyBacktracking
Decode it first. Clues, constraints, pattern and plan before any code.

A binary watch shows the hour with 4 LEDs (values 8, 4, 2, 1) and the minute with 6 LEDs (values 32, 16, 8, 4, 2, 1). The hour must be 0 to 11 and the minute 0 to 59. Given turnedOn, the number of LEDs that are lit, return every valid time the watch could show, in any order.

Format times as h:mm: the hour has no leading zero and the minute always has two digits ("1:05", not "01:5").

turnedOn = 1  →  ["0:01", "0:02", "0:04", "0:08", "0:16", "0:32", "1:00", "2:00", "4:00", "8:00"]
turnedOn = 9  →  []

Constraints

  • 0 <= turnedOn <= 10