#C918. Minimum Changes to Valid Time
Minimum Changes to Valid Time
Minimum Changes to Valid Time
Given a faulty time displayed as a string in the format (HH:MM), where (HH) represents the hours and (MM) represents the minutes, your task is to determine the minimum number of single digit changes required to convert it into a valid 24-hour format time. A valid time satisfies the condition (00 \leq HH \leq 23) and (00 \leq MM \leq 59).
For example, converting 25:61
into the valid time 20:01
requires 2 changes (changing the second digit of hours from 5 to 0, and the first digit of minutes from 6 to 0).
Your solution should read the input from standard input (stdin) and print the result to standard output (stdout). Ensure that the output is exactly one integer that represents the minimum number of changes needed.
inputFormat
The input consists of a single line containing a string in the format (HH:MM), representing the faulty time.
outputFormat
Output a single integer — the minimum number of single digit changes required to convert the faulty time into a valid 24-hour format time.## sample
23:59
0