Сompact solution (combinatorics, 3 lines, w/o bf and regexp)
Intuition\n Describe your first thoughts on how to solve this problem. \nIn general, multiply the number of valid hours by the number of valid minutes.\n# Appro
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nIn general, multiply the number of valid $$hours$$ by the number of valid $$minutes$$.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n* Precompute combinations for all possible representations of $$hours$$.\n* Use the pointer to choose the current one.\n* It\'s easy to calculate combinations of $$minutes$$, so we do it straightforwardly.\n# Complexity\n- Time complexity: $$O(1)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n---\n* You could find some other extraordinary solutions in my [profile](https://leetcode.com/almostmonday/) on the Solutions tab (I don\'t post obvious or not interesting solutions at all.)\n* If this was helpful, please upvote so that others can see this solution too.\n---\n\n# Code\n```\nclass Solution(object):\n    def countTime(self, time):\n        h, m = time.split(":")\n        p = ((h[0] == "?") << 1) | (h[1] == "?")\n        d = {0 : 1, 1 : 4 + 6 * (h[0] < "2"), 2 : 2 + (h[1] < "4"), 3 : 24}\n        \n        return d[p] * (6 if m[0] == "?" else 1) * (10 if m[1] == "?" else 1)\n```\n\nThree lines:\n```\nclass Solution(object):\n    def countTime(self, time):\n        p = ((time[0] == "?") << 1) | (time[1] == "?")\n        d = {0 : 1, 1 : 4 + 6 * (time[0] < "2"), 2 : 2 + (time[1] < "4"), 3 : 24}\n        \n        return d[p] * (6 if time[3] == "?" else 1) * (10 if time[4] == "?" else 1)\n```
['Math', 'String', 'Combinatorics', 'Enumeration', 'Python', 'Python3']