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.
simple use of union find data structure
if we are to merge two nodes check if boths parents are same or not .if they are same do nothing.else add short chain's parent to long chains parent and increment its size by long chain's length .simple :p
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Merging Communities
You are viewing a single comment's thread. Return to all comments →
simple use of union find data structure if we are to merge two nodes check if boths parents are same or not .if they are same do nothing.else add short chain's parent to long chains parent and increment its size by long chain's length .simple :p