Please check my code. I am getting WA in two test cases
Question : https://hack.codingblocks.com/app/practice/1/627/problem
Please check my code. I am getting WA in two test cases
Question : https://hack.codingblocks.com/app/practice/1/627/problem
Mistake
in unite function
par[superparent_x] = superparent_y;
sz[superparent_y] += sz[superparent_x];
sz[superparent_x] = 0;
you have to do this only if(superparent_x!=superparent_y)
Modified Code
i hope this helps
if yes hit a like and don’t forgot to mark doubt as resolved
if you have more doubts regarding this feel free to ask