Skip to content
LC-1010 Medium LeetCode

1010. Pairs of Songs With Total Durations Divisible by 60

Read the full problem statement on LeetCode.
Difficulty: medium Acceptance: 53% Topics: Array, Hash Table, Counting
View full problem on LeetCode

Reading material

Reference solution (spoiler · python)
# Time:  O(n)
# Space: O(1)

import collections


class Solution(object):
    def numPairsDivisibleBy60(self, time):
        """
        :type time: List[int]
        :rtype: int
        """
        result = 0
        count = collections.Counter()
        for t in time:
            result += count[-t%60]
            count[t%60] += 1
        return result

Solution from kamyu104/LeetCode-Solutions · MIT