As reported: Microsoft online assessment (Jan 2025, three easy questions), question 1: given four integers
A,B,C,D, count the valid times inHH:MMformat that can be made using each digit exactly once; for1, 2, 3, 4the answer is 10.
You are given four digits A, B, C, D. Arrange all four, each used exactly once, as HH:MM. A time is valid if 00 ≤ HH ≤ 23 and 00 ≤ MM ≤ 59. Return the number of different valid times.
Example 1
A = 1, B = 2, C = 3, D = 4 -> 10
12:34, 12:43, 13:24, 13:42, 14:23, 14:32, 21:34, 21:43, 23:14, 23:41. Arrangements such as 43:21 or 34:12 are invalid.
Example 2
A = 2, B = 3, C = 3, D = 2 -> 3 (22:33, 23:23, 23:32)
The same time made with the two 3s swapped counts once.
Example 3
A = 6, B = 2, C = 4, D = 7 -> 0
Constraints: 0 ≤ A, B, C, D ≤ 9.
Code runner format: four lines: A, B, C, D. Implement countValidTimes(A, B, C, D); the harness prints the result.