You are viewing a single comment's thread. Return to all comments →
I did something similar, but without using enumerate: result = sum([(ar[i] + j)%k == 0 for i in range(n) for j in ar[i+1:]])
Do you think there is any performance difference between your logic and mine? Is it a good idea to use "enumerate" instead the way I have done?
PS - a beginner here.
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 →
I did something similar, but without using enumerate: result = sum([(ar[i] + j)%k == 0 for i in range(n) for j in ar[i+1:]])
Do you think there is any performance difference between your logic and mine? Is it a good idea to use "enumerate" instead the way I have done?
PS - a beginner here.