[Java] verbose backtracking
\nclass Solution {\n    public int countTime(String time) {\n        return helper(new StringBuilder(time), 0);\n    }\n    \n    private int helper(StringBuild
```\nclass Solution {\n    public int countTime(String time) {\n        return helper(new StringBuilder(time), 0);\n    }\n    \n    private int helper(StringBuilder time, int index) {\n        \n        if(index >= time.length()) {\n            return isValid(time) ? 1 : 0;\n        }\n        \n        if(time.charAt(index) != \'?\') {\n            return helper(time, index+1);\n        }\n        \n        int count = 0;\n        \n        for(int i = 0; i <= 9; i ++) {\n            time.setCharAt(index, (char)(i+\'0\'));\n            count += helper(time, index+1);\n            time.setCharAt(index, \'?\');\n        }\n        \n        return count;\n    }\n    \n    private boolean isValid(StringBuilder time) {\n        int hh = 0;\n        hh += (time.charAt(0) - \'0\');\n        hh *= 10;\n        hh += (time.charAt(1) - \'0\');\n        \n        int mm = 0;\n        mm += (time.charAt(3) - \'0\');\n        mm *= 10;\n        mm += (time.charAt(4) - \'0\');       \n        \n        return hh >= 0 && hh <= 23 && mm >= 0 && mm <= 59;\n        \n    }\n}\n```
[]