Time Conversion
EasyP3Coding
s is a time in 12-hour format hh:mm:ssAM or hh:mm:ssPM. Convert it to 24-hour (military) format HH:mm:ss, with two digits for the hour.
12:00:00AM is 00:00:00 and 12:00:00PM is 12:00:00.
Example 1
- Input
- s = "07:05:45PM"
- Output
- "19:05:45"
Example 2
- Input
- s = "12:00:00AM"
- Output
- "00:00:00"
Example 3
- Input
- s = "12:00:00PM"
- Output
- "12:00:00"
Constraints
- s has the form hh:mm:ssAM or hh:mm:ssPM.
- 01 <= hh <= 12, 00 <= mm, ss <= 59.
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
Run checks the 3 visible tests, Submit all 11. ⌘Enter runs, ⌘⇧Enter submits.