Python Elegant & Short | RegEx
Complexity
Time complexity: O(1)
Space complexity: O(1)
RegEx versionIf you like this solution remember to upvote it to let me know.
# Complexity
- Time complexity: $$O(1)$$
- Space complexity: $$O(1)$$

# RegEx version

```python3 []
class Solution:
    def countTime(self, time: str) -> int:
        pattern = time.replace('?', '.')
        return sum(
            re.fullmatch(pattern, f'{hour:02}:{minute:02}') is not None
            for hour in range(24)
            for minute in range(60)
        )
```

If you like this solution remember to **upvote it** to let me know.


['String', 'Enumeration', 'Python', 'Python3']