• 44.4%

A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59).

Each LED represents a zero or one, with the least significant bit on the right.

For example, the above binary watch reads “3:25”.

Given a non-negative integer n which represents the number of LEDs that are currently on, return all possible times the watch could represent.

Note:

• The order of output does not matter.
• The hour must not contain a leading zero, for example “01:00” is not valid, it should be “1:00”.
• The minute must be consist of two digits and may contain a leading zero, for example “10:2” is not valid, it should be “10:02”.

https://discuss.leetcode.com/topic/59401/straight-forward-6-line-c-solution-no-need-to-explain

Straight-forward 6-line c++ solution, no need to explain

#### python

75ms, September 19, 2016

https://discuss.leetcode.com/topic/59374/simple-python-java

https://discuss.leetcode.com/topic/60319/python-dfs-and-complexity-analysis

Python DFS, and complexity analysis

Similar to other solutions out there.

The code has O(1) time complexity, because all the possible watch combinations (valid or invalid) can’t be more that 12 * 59.
Regarding space complexity, it’s also O(1) cause the DFS will have depth of maximum n, which can’t be more than 9 as per problem boundary.

62ms, September 19, 2016

#### java

36ms, September 19, 2016

https://discuss.leetcode.com/topic/59374/simple-python-java

https://discuss.leetcode.com/topic/59494/3ms-java-solution-using-backtracking-and-idea-of-permutation-and-combination

3ms Java Solution Using Backtracking and Idea of “Permutation and Combination”