Next Palindromic Time
Problem statement
Given a valid 24-hour time time in HH:MM format, return the first strictly later time whose four digits form a palindrome.
Advance in one-minute steps and wrap from 23:59 to 00:00. The input itself is never returned unless a full day has elapsed.
Function
nextPalindromicTime(time: String) → StringExamples
Example 1
time = "12:21"return = "13:31"13:31 is the first later valid time whose digits read the same in both directions.
Example 2
time = "23:32"return = "00:00"No later palindromic time remains that day, so the search wraps to midnight.
Example 3
time = "05:50"return = "10:01"The next palindromic four-digit clock value after 0550 is 1001.
Constraints
time.length == 5.time[2] == ':'.timeis a valid zero-padded 24-hour time from00:00through23:59.