We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
s=[x%kforxins]s1=[xforxinsifx!=0]if0ins:s1.append(0)counter=[0]*(k+1)forxins1:counter[x]+=1count=0;foriinrange(0,k//2+1):max_k=max(counter)max_ind_rem=counter.index(max_k)ifmax_ind_rem*2==k:ifmax_ind_rem*2==k:count=count+1else:count=count+max(1,counter[k-max_ind_rem])else:count+=max_k#we include alreadycounter[max_ind_rem]=0;counter[k-max_ind_rem]=0returncount
Cookie support is required to access HackerRank
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 →
My versiion: