Union Find - Quick Find algorithm.