### Solution 1

Just turn the clock forwards one minute at a time until you reach a time with the original digits.

```
from datetime import *
class Solution(object):
def nextClosestTime(self, time):
digits = set(time)
while True:
time = (datetime.strptime(time, '%H:%M') + timedelta(minutes=1)).strftime('%H:%M')
if set(time) <= digits:
return time
```

### Solution 2

Return the smallest time that uses the given digits, just make being larger than the input a priority.

```
def nextClosestTime(self, time):
return min((t <= time, t)
for i in range(24 * 60)
for t in ['%02d:%02d' % divmod(i, 60)]
if set(t) <= set(time))[1]
```

Golfed:

```
def nextClosestTime(self, T):
return min((t<=T,t)for i in range(1440)for t in['%02d:%02d'%divmod(i,60)]if set(t)<=set(T))[1]
```