LeetCode solutions

2345. Minimum Number of Operations to Convert Time

My accepted Python solution to LeetCode problem 2345, Minimum Number of Operations to Convert Time, running in 0ms.

  • Difficulty: Easy
  • Python
  • Runtime 0ms
  • Memory 17.3MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 0ms, memory 17.3MB, accepted 2026-01-01.

python
class Solution:
    def convertTime(self, current: str, correct: str) -> int:
        def toMinutes(time):
            h, m = map(int, time.split(':'))
            return h * 60 + m
        
        diff = toMinutes(correct) - toMinutes(current)
        ops = 0
        for inc in [60, 15, 5, 1]:
            ops += diff // inc
            diff %= inc
        return ops

Source