I have got stuck on one question from the contest "koder kombat"
https://www.codechef.com/KOKT2015/problems/KOKT01
I have tried to solve this question using array and linked list but both are taking too long and I am getting TLE error. I have referred to this solution:-
https://www.codechef.com/viewsolution/8623244
they are accomplishing this using some tree data structure, I banged my head a lot but couldn't figure out what's under the hood.
Please help me out with this.
Thank you