Using index; Beats 100%
Complexity
Time complexity:
O(n) where, n = length of string; which in this case will always be 5.
Space complexity:
O(1)Code
\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n) where, n = length of string; which in this case will always be 5.\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(1)\n# Code\n```python3 []\nclass Solution:\n    def countTime(self, time: str) -> int:\n        ans = 1\n        skip = False\n        for i in range(5):\n            if skip:\n                skip = False\n                continue\n            if time[i] == "?":\n                if i == 0 and time[i + 1] == "?":\n                    ans *= 24\n                    skip = True\n                elif i == 0:\n                    if int(time[i + 1]) < 4:\n                        ans *= 3\n                    elif int(time[i + 1]) >=4:\n                        ans *= 2\n                elif i == 1:\n                    if int(time[i - 1]) <= 1:\n                        ans *= 10\n                    elif int(time[i - 1]) == 2:\n                        ans *= 4\n                elif i == 3:\n                    ans *= 6\n                elif i == 4:\n                    ans *= 10\n        return ans\n```
['Python3']