3 ms·
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_dat
by twanvl 10y ago
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 https://en.wikipedia.org/wiki/Disjoint-set_data_structure. That should make your function fairly easy to implement.
- Patient0 10y agoThanks for that - I'll take a look!