Find the max of the key which is having the product max of key and value
I got the output, I am in search of best solution
a = [3,4,5,5,6,6,6,7,7]
c = set(a)
counts = {}
for i in a:
if i in counts:
counts[i] += 1
else:
counts[i] =1
#counts
t = [k*v for k,v in counts.items()]
max_index = t.index(max(t))
list(c)[max_index]
6
NO error, how to optimize the code. need list comprehension at the position
for[k*v for k,v in counts.items()]. Can i add map function to this?