I have an input in a nested list like:
input = [ [1,2],[1,3],[1,5],[2,3],[2,5],[3,1],[3,3],[4,6] ]
And I want to merge the same element together as output like:
output = [ [1,2,3,5], [4,6] ]
So far, I'd tried with defaultdict , unique and set().intersection to generate the result, but not as expected.
Is there any easier way to accomplish this? I'll be appreciated with any idea can help.
Thanks!