# 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; } } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up