Binary Watch

Problem Id: 401 Difficulty: Easy


Intuition

Solution


class Solution:
    def readBinaryWatch(self, num: int) -> List[str]:
        ans = []
        for i in range(0, 12):
            for j in range(0, 60):
                if (bin(i) + bin(j)).count('1') == num:
                    ans.append(str(i) + ':' + ('00' + str(j))[-2:])
        return ans