✅ [Python] fastest (100%) & easiest solution (with detailed comments)
This solution employs a set of simple conditional statements. It demonstrated 28 ms runtime (100.00%) and used 13.8 MB memory (75.00%). Time complexity is const
This [**solution**](https://leetcode.com/submissions/detail/823084984/) employs a set of simple conditional statements. It demonstrated **28 ms runtime (100.00%)** and used **13.8 MB memory (75.00%)**. Time complexity is constant: **O(1)**. Space complexity is constant: **O(1)**. Detailed comments are provided.\n\n**IF YOU LIKE THIS SOLUTION, PLEASE UPVOTE.**\n```\nclass Solution:\n    \n    def countTime(self, time: str) -> int:\n        \n        # [1] if all symbols are digits, there is only 1 valid time\n        t = 1\n        \n        # [2] if minute digits have unknown symbols, they independently\n        #     generate additional combinations\n        if time[3] == "?": t *= 6\n        if time[4] == "?": t *= 10\n\n        # [3] however, digits in the number of hours are not independent\n        if time[0:2] == "??":\n            t *= 24\n        elif time[0] == "?" and time[1] != "?": \n            t *= 2 if time[1] in ["4", "5", "6", "7", "8", "9"] else 3\n        elif time[1] == "?" and time[0] != "?": \n            t *= 10 if time[0] in ["0", "1"] else 4\n        \n        return t\n```\n
['Python']