Tap here to switch tabs
Problem
Submissions

Problem: Next Closest Time

med
30 min
Try to solve the Next Closest Time problem.

Statement

Given a string time representing a time of day in the format "HH:MM", return the next closest valid time that can be formed by reusing the digits present in time. Each digit may be used an unlimited number of times.

If no valid time can be formed that occurs later on the same day, return the earliest valid time formed from the digits, which occurs on the following day.

Constraints:

  • time.length =5= 5

  • time is a valid time in the format "HH:MM".

  • 0≤extHH<240 \leq ext{HH} < 24

  • 0≤extMM<600 \leq ext{MM} < 60

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Next Closest Time

med
30 min
Try to solve the Next Closest Time problem.

Statement

Given a string time representing a time of day in the format "HH:MM", return the next closest valid time that can be formed by reusing the digits present in time. Each digit may be used an unlimited number of times.

If no valid time can be formed that occurs later on the same day, return the earliest valid time formed from the digits, which occurs on the following day.

Constraints:

  • time.length =5= 5

  • time is a valid time in the format "HH:MM".

  • 0≤extHH<240 \leq ext{HH} < 24

  • 0≤extMM<600 \leq ext{MM} < 60