Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Can we solve this problem using a set or map?
Sequentially process pairs from moveFrom[i] and moveTo[i]. In each step, remove the occurrence of moveFrom[i] and add moveTo[i] into the set.