Q1: Essentially, write a union function, pretty simple with hashmaps.
Q2: Not sure what leetcode problem would be equivelent to this, however here is the description:
Given a list of objects (Each having some weight) that you want to move from point A to B (Note is that you cant rearrange the items), and also given that you want to carry at least weight (w) and have a maximum weight (W) for all the trips, what is the minimum number of trips needed, if it is possible.
I tried to use DP to solve this problem, but wasn't able to fully work it out. I think this is a Hard level problem, which I don't have a lot of experience with. I also think you have to do this in O(n^2) instead of O(n) but I can't prove that.
Any help on figuring out this problem is appricated!