Say I have a dictionary like this
D = {'a': [1,2,3], 'b': [2,3,4], 'c': [3,4,5]}
For each unique element present across all the lists, I want to find the associated dict keys.
The wanted output is thus:
out = {1: ['a'], 2: ['a', 'b'], 3: ['a', 'b', 'c'], 4: ['b', 'c'], 5: ['c']}
How do I do this most efficiently?
EDIT: I need to do this for a large dict with ~100 keys and each list between 50-10000 elements