2224. Minimum Number of Operations to Convert Time

Обновлено: 2024-03-12
1 мин
[]

Содержание

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