2021-12-24

Maximum dictionary keys should have equal number of values [duplicate]

Given two lists need to map keys and values respectively such that maximum keys should have equal number of values.

Example: Input :

['a', 'b', 'c', 'd']
[3,2,8,4,7,9,0,4,5,6,7] 

Output:

{'a':[3,2,8], 'b':[4,7,9], c:[0,4,5], 'd':[6,7]}

What could to be a good algorithm for this problem ? I was not able to write any code hence not providing any. Any help is highly appreciated.



from Recent Questions - Stack Overflow https://ift.tt/32yJf8X
https://ift.tt/eA8V8J

No comments:

Post a Comment