Permutations
Intuition\nTo calculate all valid times we can multiply all the no. of possibilities of the missing digit.\n Describe your first thoughts on how to solve this p
# Intuition\nTo calculate all valid times we can multiply all the no. of possibilities of the missing digit.\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nFirst we extract all the digits.\nThen we conditionally check what to multiply.\n<!-- Describe your approach to solving the problem. -->\n\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# Code\n```\nclass Solution {\npublic:\n    int countTime(string time) {\n        int h1, h2, m1, m2;\n        h1 = h2 = m1 = m2 = -1; // default -1\n        // extracting digits\n        if(isdigit(time[0]))\n            h1 = time[0] - \'0\';\n        if(isdigit(time[1]))\n            h2 = time[1] - \'0\';\n        if(isdigit(time[3]))\n            m1 = time[3] - \'0\';\n        if(isdigit(time[4]))\n            m2 = time[4] - \'0\';\n        \n        int res = 1;\n        \n        if(h1 == -1 && h2 == -1)\n            res *= 24;\n        else if(h1 == -1)\n            res *= (h2 < 4) ? 3 : 2;\n        else if(h2 == -1)\n            res *= (h1 < 2) ? 10 : 4;\n        \n        if(m1 == -1 && m2 == -1)\n            res *= 60;\n        else if(m1 == -1)\n            res *= 6;\n        else if(m2 == -1)\n            res *= 10;\n        return res;\n    }\n};\n```
['Math', 'C++']