Skip to content

Commit c732bea

Browse files
authored
Update next-closest-time.py
1 parent 3586639 commit c732bea

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Python/next-closest-time.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
# Time: O(1)
22
# Space: O(1)
33

4+
# Given a time represented in the format "HH:MM",
5+
# form the next closest time by reusing the current digits.
6+
# There is no limit on how many times a digit can be reused.
7+
#
8+
# You may assume the given input string is always valid.
9+
# For example, "01:34", "12:09" are all valid. "1:34", "12:9" are all invalid.
10+
#
11+
# Example 1:
12+
#
13+
# Input: "19:34"
14+
# Output: "19:39"
15+
# Explanation: The next closest time choosing from digits 1, 9, 3, 4, is 19:39, which occurs 5 minutes later.
16+
# It is not 19:33, because this occurs 23 hours and 59 minutes later.
17+
#
18+
# Example 2:
19+
#
20+
# Input: "23:59"
21+
# Output: "22:22"
22+
# Explanation: The next closest time choosing from digits 2, 3, 5, 9, is 22:22.
23+
# It may be assumed that the returned time is next day's time since it is smaller than the input time numerically.
24+
425
class Solution(object):
526
def nextClosestTime(self, time):
627
"""

0 commit comments

Comments
 (0)