problem link:
Discuss: you can solve this problem by simply using disjoint set. just rank the set. and print for every new element. and there is no tricky part. you can use map for using number instead of string.
try yourself, before see the code
Discuss: you can solve this problem by simply using disjoint set. just rank the set. and print for every new element. and there is no tricky part. you can use map for using number instead of string.
try yourself, before see the code