Java Solution || Beats 0ms beats 100% || with Comments
Approach\n Describe your approach to solving the problem. \nThis solution belongs to @conchwu\n\nIt\'s a little difficult to decode initially, so I added commen
# Approach\n<!-- Describe your approach to solving the problem. -->\nThis solution belongs to @conchwu\n\nIt\'s a little difficult to decode initially, so I added comments incase it helps others.\n\nAll credits to her! :)\n\n# Code\n```\nclass Solution {\n    public int countTime(String time) {\n        if (time.equals("??:??"))\n            return 24 * 60;\n\n        int res = 1;\n\n        // if both hour hands are empty, 24 possibilities.\n        if (time.charAt(0) == \'?\' && time.charAt(1) == \'?\') {\n            res = res * 24;\n        } else if (time.charAt(0) == \'?\') {\n            /**\n             * if 2nd hand already at 4 or above, first hand can only have 2 possibilities -\n             * 0 and 1\n             * if 2nd hand = 5 => 05:00, 15:00, (25:00 is not possible.)\n             * if 2nd hand less than 4, then 3 possibilities\n             * if 2nd hand = 2 => 02:00, 12:00, 22:00 - all 3 possible\n             */\n            if (time.charAt(1) - \'0\' >= 4)\n                res = res * 2;\n            else\n                res = res * 3;\n        } else if (time.charAt(1) == \'?\') {\n            // if hour hand is >= 2, only 4 possibilities for min hand {20, 21, 22, 23}\n            if (time.charAt(0) - \'0\' >= 2)\n                res = res * 4;\n            /// or else 10 possibilities for hour 0X and hour 1X {00, 01, 02... 09} or {10,\n            /// 11, 12... 19}\n            else\n                res = res * 10;\n        }\n        // if 2nd min hand is empty, 10 possibilities, XX:X0, XX:X1, XX:X2... XX:X9\n        // after 19 min, it needs to go to 20 min, it can\'s be 1(10) min\n        if (time.charAt(4) == \'?\')\n            res = res * 10;\n        // if 1st min hand is empty, 6 possibilities, XX:0X, XX:1X, XX:2X... XX:5X\n        // after 59 min, it needs to go back to 00 min, it can\'t go to 63 min\n        if (time.charAt(3) == \'?\')\n            res = res * 6;\n        return res;\n    }\n}\n```
['Java']