Loading repovive.com/problems/classics/21
Implement a Union-Find (Disjoint Set Union) data structure that supports the following operations on elements (numbered 1 to ):
UNION u v: Merge the sets containing elements and FIND u v: Check if elements and are in the same setInitially, each element is in its own set.
For this input, the required output is NO YES YES NO.
For this input, the required output is YES YES.
For this input, the required output is NO NO NO NO.