Skip to content
Decoder

Binary Watch

Easy

Problem

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").

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
[]

Constraints

  • 0 <= turnedOn <= 10

Read it once before you touch anything

Want some pressure? Start the timer. In an interview you get about two minutes to understand the problem.

  1. 1Read the goalWhat goes in, what comes out
  2. 2Scan the examplesCheck one by hand
  3. 3Note the constraintsThey set your Big O
Say what it asks in one sentence
Say it out loud first, then compare with ours.