Leetcode 1055 Solution

This article provides solution to leetcode question 1055 (pairs-of-songs-with-total-durations-divisible-by-60)

https://leetcode.com/problems/pairs-of-songs-with-total-durations-divisible-by-60

Solution

class Solution: def numPairsDivisibleBy60(self, time: List[int]) -> int: m = collections.Counter() for t in time: m[t % 60] += 1
print(m) ans = 0 for v in m: if v == 0 or v == 30: ans += m[v] * (m[v] - 1) / 2 else: ans += m[v] * m[60 - v] / 2 return int(ans)