You are viewing a single comment's thread. Return to all comments →
public static int divisibleSumPairs(int n, int k, List<Integer> ar) { Map<Integer,Integer> mp=new HashMap<>(); int cnt=0; for(int i=0;i<ar.size();i++){ int rem=ar.get(i)%k; int com=(k-rem==k?0:k-rem); if(mp.containsKey(com)){ cnt+=mp.get(com); } mp.put(rem,mp.getOrDefault(rem,0)+1); } return cnt; } } ****
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 →