Skip to content

Instantly share code, notes, and snippets.

@luoheng23
Created December 30, 2019 01:49
Show Gist options
  • Save luoheng23/fbf4998254a0806489f71909fef47026 to your computer and use it in GitHub Desktop.
Save luoheng23/fbf4998254a0806489f71909fef47026 to your computer and use it in GitHub Desktop.
class Solution:
def readBinaryWatch(self, num: int) -> List[str]:
"""copy from 思君满月"""
ret = []
for hour in range(12):
for minute in range(60):
if (bin(hour) + bin(minute)).count('1') == num:
ret.append('%d:%02d' % (hour, minute))
return ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment