Problem Link

Please help me to understand the solution by Yash Chandnani

I have understood the editorial but this solution is very neat and clean but I am not able to understand.

Problem Link

Please help me to understand the solution by Yash Chandnani

I have understood the editorial but this solution is very neat and clean but I am not able to understand.

1 Like

I just want to know logic behind this line

`while(cnt[y]==p-1) cnt[y]=0,y++;`

i think the video by ROmeo Fantastic is really Fantastic for this problem

1 Like

cnt array stores the sum of elements added to set 2, so if this sum becomes equal to x^p, you can reset the array ie s1==s2, and continue by adding the next element to set 1.

This was a great problem…