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
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 0ms, memory 17.3MB, accepted 2026-01-01.
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