You are viewing a single comment's thread. Return to all comments →
public static int nonDivisibleSubset(int k, List s) { // Write your code here int [] remindercountes = new int [k] ; int count =0 ;
for (int i : s) { remindercountes[i%k]++ ; } for (int j =1 ; j <=(k/2);j++ ) { if (j== k - j) { count++; continue ; } count+= Math.max(remindercountes[j], remindercountes[k - j]) ; } if (remindercountes[0] > 0) { count++; } return count ; }``````
Seems like cookies are disabled on this browser, please enable them to open this website
Non-Divisible Subset
You are viewing a single comment's thread. Return to all comments →
public static int nonDivisibleSubset(int k, List s) { // Write your code here int [] remindercountes = new int [k] ; int count =0 ;