We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I'd argue union by rank isn't necessary, since you are already using path compression. But it doesn't hurt either and since for this challenge you need to track the size anyway, might as well do it.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Friend Circle Queries
You are viewing a single comment's thread. Return to all comments →
I'd argue union by rank isn't necessary, since you are already using path compression. But it doesn't hurt either and since for this challenge you need to track the size anyway, might as well do it.