-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsolution.py
29 lines (27 loc) · 1.04 KB
/
solution.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class Solution(object):
def readBinaryWatch(self, num):
"""
:type num: int
:rtype: List[str]
"""
pre_hours_map = {
0: ['0'],
1: ['1', '2', '4', '8'],
2: ['3', '5', '9', '6', '10'],
3: ['7', '11']
}
pre_mins_map = {
0: ['00'],
1: ['01', '02', '04', '08', '16', '32'],
2: ['03', '05', '09', '17', '33', '06', '10', '18', '34', '12', '20', '36', '24', '40', '48'],
3: ['07', '11', '19', '35', '13', '21', '37', '25', '41', '49', '14', '22', '38', '26', '42', '50', '28', '44', '52', '56'],
4: ['15', '23', '39', '27', '43', '51', '29', '45', '53', '57', '30', '46', '54', '58'],
5: ['31', '47', '55', '59']
}
res = []
for i in range(4):
if pre_mins_map.get(num - i):
for x in pre_hours_map.get(i):
for y in pre_mins_map.get(num - i):
res.append(x + ':' + y)
return res