Nice hack of converting set into a sorted list
@FLAGbigoffer Yes, you are right. I have added BFS method.
Thanks for your very simple algorithm! No need to use map though, unordered_map would do just as fine.
And we can do path compression at the same time of find(), saves some recursions.
Nice solution! Here's another implementation with very similar idea of just using one hashMap and lists instead of using multiple HashMap and HashSet.
No one has replied
@jmangue Uh... what the f is C# doing? Why/how does it sort like that?
@claytonjwong glad you liked it. Thanks for sharing your solution.
I think accountsColSize should be the size of each accounts[i] (as you said).
But in the prototype
It is a single integer int accountsColSize!!! Do you know why?
I think it should be an array (as you said 4, 2, 2).
Do you think this might cause the warning?
Using union find is a good idea!
Disabled Categories are greyed out
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.