Brute Force generate all possible times (click at your own risk)
Just replace each \'?\' with all possible values (0-9) and store each string in an array and check if the time is valid\n\nclass Solution {\npublic:\n    void h
Just replace each \'?\' with all possible values (0-9) and store each string in an array and check if the time is valid\n```\nclass Solution {\npublic:\n    void helper(string time, int i , string t, vector<string>& times) {\n        if (i == time.size()) {\n            times.push_back(t);\n            return;\n        }\n        if (time[i] == \'?\') {\n            string chars = "0123456789";\n            for (auto e : chars)\n                helper(time, i + 1, t + e, times);\n        }\n        else\n            helper(time, i + 1, t + time[i], times);\n    }\n\t\n\t// returns true if time is valid\n    bool isValid(string time) {\n\t\t// get the hours\n        int hrs;\n\t\t// handling preceeding zeros\n        if (time[0] == \'0\')\n            hrs = time[1] - \'0\';\n        else\n            hrs = stoi(time.substr(0, 2));\n\t\t// get the mins\n        int mins;\n        if (time[3] == \'0\')\n            mins = time[3] - \'0\';\n        else\n            mins = stoi(time.substr(3, 2));\n        return hrs <= 23 and mins <= 59;\n    }\n\t\n    int countTime(string time) {\n        vector<string> times;\n\t\t// generates all possible times and stores it in  arr - times.\n        helper(time, 0, "", times);\n        int res = 0;\n        for (auto t : times) if (isValid(t)) res++;\n        return res;\n    }\n};\n```
['Recursion']