Structural pattern matching
Minutes are easy. For hours, we there could be be 1, 2, 3, 4, 10 or 24 combinations.\n\nPython 3\nJust for fun - using structural pattern matching.\npython\ncla
Minutes are easy. For hours, we there could be be 1, 2, 3, 4, 10 or 24 combinations.\n\n**Python 3**\nJust for fun - using structural pattern matching.\n```python\nclass Solution:\n    def countTime(self, t: str) -> int:\n        mm = (6 if t[3] == \'?\' else 1) * (10 if t[4] == \'?\' else 1)\n        match [t[0], t[1]]:\n            case (\'?\', \'?\'):\n                return mm * 24\n            case (\'?\', (\'0\' | \'1\' | \'2\' | \'3\')):\n                return mm * 3\n            case (\'?\', _):\n                return mm * 2\n            case ((\'0\' | \'1\'), \'?\'):\n                return mm * 10\n            case (_, \'?\'):\n                return mm * 4\n        return mm\n```\n\n**C++**\n```cpp\nint countTime(string t) {\n    int res = 1;\n    if (t[0] == \'?\')\n        res = t[1] == \'?\' ? 24 : t[1] < \'4\' ? 3 : 2;\n    else if (t[1] == \'?\')\n        res = t[0] < \'2\' ? 10 : 4; \n    return res * (t[3] == \'?\' ? 6 : 1) * (t[4] == \'?\' ? 10 : 1);\n}\n```
['C', 'Python3']