Python--->Reduce The Half Of Array Size----->(Collection ,Counter) Best Use

from collections import Counter
d=Counter(arr)
a=d.values()
k=[]
for i in a:
k.append(i)
k.sort()
c=0
t=len(arr)
for i in k[::-1]:
if(t>len(arr)//2):
t=t-i
c=c+1
else:
break
return c

Comments (1)