You are viewing a single comment's thread. Return to all comments →
This is a way simpler solution with Java 8:
return IntStream.range(0,n).map(x -> IntStream.range(x+1,n).map(y -> (ar[x]+ar[y])%k==0?1:0).sum()).sum();
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 →
This is a way simpler solution with Java 8: