1055. Pairs of Songs With Total Durations Divisible by 60
My accepted Python solution to LeetCode problem 1055, Pairs of Songs With Total Durations Divisible by 60, running in 13ms.
- Difficulty: Medium
- Python
- Runtime 13ms
- Memory 20.8MB
- 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 13ms, memory 20.8MB, accepted 2026-01-02.
class Solution:
def numPairsDivisibleBy60(self, time: List[int]) -> int:
# Count remainders when divided by 60
remainders = [0] * 60
count = 0
for t in time:
remainder = t % 60
# Find complement that makes sum divisible by 60
complement = (60 - remainder) % 60
count += remainders[complement]
remainders[remainder] += 1
return count