Minimum Number of Operations to Convert Time LeetCode solution in Python

1
class Solution:
2
def convertTime(self, current: str, correct: str) -> int:
3
def get_time(t):
4
hh, mm = t.split(":")
5
return int(hh) * 60 + int(mm)
6

7
current, correct = get_time(current), get_time(correct)
8
operations = 0
9
diff = correct - current
10

11
for mins in [60, 15, 5, 1]:
12
quotient, remainder = divmod(diff, mins)
13
operations += quotient
14
diff = remainder
15

16
return operations

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0