✅[C++] Standard combination problem (Mathematics explained)
Thought Process:\n\nInput: time = "??:??"\nOutput: 1440\n\nThe above testcase is the solution!But, how?\nLet\'s see couple of cases possible :-\n\n# For Hours (
# Thought Process:\n```\nInput: time = "??:??"\nOutput: 1440\n```\nThe above testcase is the solution!But, how?\nLet\'s see couple of cases possible :-\n\n# *For Hours (hh)*\n**Case 1**\n```hh = "??"```\nSince **hh[0]** and **hh[1]** both are unknown. Therefore 24 combinations are possible, hence**ans=24**\n\n**Case 3**\n```hh = "?(0-9)" ```\n\n*Subcase 1* \n```hh = "?(0-3)"```\nIf **hh[1] is between 0 and 3, we can have hh[0] as 0, 1 ,2.** Therefore, 3 combinations are possible. Hence **ans=3**\n\n*Subcase 2* \n```hh = "?(4-9)"```\nIf **hh[1] is between 4 and 9, we can have hh[0] as 0, 1**. Therefore, 2 combinations are possible.  Hence **ans=2**\n\n**Case 4**\n```hh = "(0-1)?"```\nIf **hh[0] is either 0 or 1**. Therefore, 10 combinations **(? = (0-9))** are possible. Hence, **ans=10**\n\n**Case 5**\n```hh = "2?"```\nPossible combinations are **20,21,22,23**, therefore **ans=4**\n\n# *For Minutes*\n**For mm[0] there are 6 possibilities (0-5) whereas for mm[1] there are 10 possibilities (0-9).**\n\n**Case 1**\n```mm = "??"```\nPossible combinations are 60. Therefore **ans2 = 60**.\n\n**Case 2**\n```mm = "?(0-9)"```\nPossible combinations are 6. Therefore **ans2 = 6**.\n\n**Case 3**\n```mm = "(0-5)?"```\nPossible combinations are 10. Therefore **ans2 = 10**.\n\nFinal result would be **ans * ans2**.\n\n```\nclass Solution {\npublic:\n    int countTime(string time) {\n        int ans = 1, ans2 = 1;\n        \n        if (time[0] == \'?\' && time[1] == \'?\') ans = 24;\n        else if (time[0] == \'?\' && time[1] != \'?\'){            \n            if (time[1]-\'0\' <= 3) ans = 3;\n            else ans = 2;\n        }\n        else if ((time[0] == \'1\' || time[0] == \'0\') && time[1] == \'?\') ans =10;\n        else if (time[0] == \'2\' && time[1] == \'?\') ans=4;\n        \n        if (time[3] == \'?\') ans2 = 6;\n        if (time[4] == \'?\') ans*=10;\n        \n        return ans*ans2;\n    }\n};\n```\n\n# Complexity\n**TC:** O(1)\n**SC:** O(1)\n
['C']