---
# System prepended metadata

title: 2437. Number of Valid Clock Times
tags: [Leetcode, Easy]

---

# 2437. Number of Valid Clock Times
###### tags: `Leetcode` `Easy`
Link: https://leetcode.com/problems/number-of-valid-clock-times/description/
## Code
```java=
class Solution {
    public int countTime(String time) {
        int ans = 1;
        if(time.charAt(0)=='?' && time.charAt(1)=='?') ans*=24;
        else{
            if(time.charAt(1)=='?'){
                if(time.charAt(0)=='1'||time.charAt(0)=='0') ans*=10;
                else ans*=4;
            }
            else if(time.charAt(0)=='?'){
                if(time.charAt(1)>='4') ans*=2;
                else ans*=3;
            }
        }
        if(time.charAt(3)=='?' && time.charAt(4)=='?') ans*=60;
        else{
            if(time.charAt(3)=='?') ans*=6;
            else if(time.charAt(4)=='?')ans*=10;
        }
        return ans;
    }
}
```