FastPrepNext Palindromic Time
Problems/Next Palindromic Time

Next Palindromic Time

Amazon logoAmazon● MediumFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: The source asks for the next palindromic time but omits whether the current minute counts and how midnight is handled. The judged version uses the next strictly later minute with daily wraparound, so the core task match is about 92%.

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) → String

Examples

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] == ':'.
  • time is a valid zero-padded 24-hour time from 00:00 through 23:59.

More Amazon problems

  • Count Adjacent Symbol Pairs for BPEONSITE INTERVIEW · Seen Nov 2026
  • First Non-Repeating CharacterOA · ONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
See Amazon hiring insights
Saved
class Solution {
    public String nextPalindromicTime(String time) {
      // write your code here
    }
}
Checking account…