2224. Minimum Number of Operations to Convert Time

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 2224

class Solution:
    def convertTime(self, current: str, correct: str) -> int:
        a = int(current[:2]) * 60 + int(current[3:])
        b = int(correct[:2]) * 60 + int(correct[3:])
        res, d = 0, b - a
        for i in [60, 15, 5, 1]:
            res += d // i
            d %= i
        return res