Cycle detection using dsu

sir can you just tell where my code is wrong i have marked my mistake in code

sir please reply i am wating for your reply

@YASHMATHURIA123
Your code is correct but there is mistake in line 28 it should be par[x]=y;