Re:The Programming Interview from Hell
by twanvl on Monday February 20, 2017 @09:51AM
(#13687681)
The standard data structure to look for in this case is the disjoint-set data structure (also called union-find), https://en.wikipedia.org/wiki/Disjoint-set_data_structure. That should make your function fairly easy to implement.
[ Parent
| on HN ]