The problem should be really simple, i just need to find the connected component and each node represent an index of the array the sort the value of all indices and put them in the correct position, do the same for each component.
But i am getting WA test 16 for unknown reason i even checked all the small test cases and my code passed so hopefully someone can help..
Problem link : Here. Solution link : Here.
Thanks in advance.