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.
I'm wondering the same thing. He adds that 1 at the end if k%2. But how do you guarantee that it exists?. I think the right code should be:
n,k=map(int,raw_input().strip().split(" "))arr=map(int,raw_input().strip().split(" "))residuals=[i%kforiinarr]counter=[0]*kforrinresiduals:counter[r]+=1# max one element with residual 0c=min(counter[0],1)foriinrange(1,(k//2)+1):ifi!=k-i:c+=max(counter[i],counter[k-i])else:c+=min(counter[i],1)print(c)
But somehow his code gets lucky and passes all cases.
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 →
I'm wondering the same thing. He adds that 1 at the end if k%2. But how do you guarantee that it exists?. I think the right code should be:
But somehow his code gets lucky and passes all cases.