Save 25%Black Friday: 25% off all plans — use code BLACKFRIDAY2026 at checkout. Ends Friday, Dec 4.Claim the deal

Given four integers A, B, C, and D representing digits, determine the number of valid times that can be displayed on a 24-hour digital clock using each digit exactly once, where the valid time range spans from "00:00" to "23:59".

Constraints:

  • A, B, C, and D are integers within the range [0, 9].

Example 1:

Input: A = 1, B = 8, C = 3, D = 2 Output: 6 Explanation: The valid times are "12:38", "13:28", "18:23", "18:32", "21:38", and "23:18".

Example 2:

Input: A = 2, B = 3, C = 3, D = 2 Output: 3 Explanation: The valid times are "22:33", "23:23", and "23:32".

Example 3:

Input: A = 6, B = 2, C = 4, D = 7 Output: 0


Accepted
1.4k/2.9k
Acceptance Rate49.5%
Test Cases
Input
a =
b =
c =
d =
Output
Expected