class Solution(object):
def numPairsDivisibleBy60(self, time):
"""
:type time: List[int]
:rtype: int
"""
num=0
number=[0 for _ in range(60)] # number: numbers of couple
length=len(time) #length of time
for i in range(length):
j=time[i]%60
number[j]=number[j]+1
for j in range(1,30):
num=num+number[j]*number[60-j]
num0=number[0]
num0=num0*(num0-1)/2
num3=number[30]
num3=num3*(num3-1)/2
num=num+num3+num0
return num
解题思路:灵感来源于哈希函数,详情:https://blog.csdn.net/yyyljw/article/details/80903391