We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
defdivisibleSumPairs(n,k,ar):# a map to store counts of each modulu classmods=k*[0]# counting each classfornuminar:mods[num%k]+=1count=0fornuminar:# this will maintain i < jmods[num%k]-=1# second module takes care of case mod == kmod=(k-num%k)%kcount+=mods[mod]returncount
Divisible Sum Pairs
You are viewing a single comment's thread. Return to all comments →