You are viewing a single comment's thread. Return to all comments →
using c++
int nonDivisibleSubset(int k, vector<int> s) { int a[k]; int n1=s.size(),max=0; for(int i=0;i<k;i++) { a[i]=0; } for(int i=0;i<n1;i++) { a[s[i]%k]++; } for(int j=0;j<=k/2;j++) { if(j==0) { if(a[j]>0) max++; } else if (j==k-j) { if(a[j]>0) max++; } else { if(a[j]>a[k-j]) max+=a[j]; else { max+=a[k-j]; } } } return max; }
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 →
using c++