What is the appropriate way to solve this question, I solve this question using circular linked list(Deleting all the alternate elements untless one element left). and element which is left is the answer. But this approach is taking too long time.

https://www.codechef.com/viewsolution/8281392

I referred this solution but I didn’t get what approach the guy used.

Thanks in advance.