I have been solving 1354D - Multiset for quite a while now and am getting MLE on test case 8 ever since (7 attempts)!
Though I am using a single array of size n for the Tree because it has strict memory limit, I am confused how to optimize it further.
Here are my submissions:
Attempt 7 : 158777250 (tried making the tree array static...idk how that would help but still)
Attempt 3-6 : tried various combinations for getting the 1st element for final output/ removing some pre-declared arrays, methods/etc.
Attempt 2 : 158775164 (removed frequency array)
Attempt 1 : 158774360 (2 arrays : 1 for frequency and other for Tree)
How can this issue be resolved?
Thanks in advance! :)