Skip to content

Latest commit

 

History

History
34 lines (29 loc) · 757 Bytes

Question_2437.md

File metadata and controls

34 lines (29 loc) · 757 Bytes

LeetCode Records - Question 2437 Number of Valid Clock Times

Attempt 1: Check hour and minute

class Solution {
    public int countTime(String time) {
        char[] arr = time.toCharArray();

        int count = 1;
        if (arr[0] == '?') {
            if (arr[1] == '?') {
                count = 24;
            } else {
                count = arr[1] >= '4' ? 2 : 3;
            }
        } else if (arr[1] == '?') {
            count = arr[0] == '2' ? 4 : 10;
        }

        if (arr[3] == '?') {
            count *= 6;
        }
        if (arr[4] == '?') {
            count *= 10;
        }
        
        return count;
    }
}
  • Runtime: 0 ms (Beats: 100.00%)
  • Memory: 41.36 MB (Beats: 24.91%)