You are viewing a single comment's thread. Return to all comments →
The fact that the hardest part on this thing was remembering how mods work other than checking if smt is divisible xd
int nonDivisibleSubset(int k, vector<int> s) { vector<int> mods(k, 0); for (int x : s) { mods[x % k]++; } int count = 0; if (mods[0] > 0) count++; for (int i = 1; i <= k / 2; i++) { if (i == k - i) { count++; } else { count += max(mods[i], mods[k - i]); } } 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 →
The fact that the hardest part on this thing was remembering how mods work other than checking if smt is divisible xd