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.
result=0
for num in range(n):
for num1 in range(n):
if num!=num1 and (ar[num]+ar[num1])%k==0:
result=result+1
if result%2==0:
return result//2
elif result%2==1:
return result//2+1
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Divisible Sum Pairs
You are viewing a single comment's thread. Return to all comments →
result=0 for num in range(n): for num1 in range(n): if num!=num1 and (ar[num]+ar[num1])%k==0: result=result+1 if result%2==0: return result//2 elif result%2==1: return result//2+1