I am trying the following problem.
This is my code.
I am using multiset in C++. I read from here that erase(iterator) works in amortized constant time and insert(val) works in logarithmic time. According to me, my codes worst case complexity is O(Nlog(N)), but it gives TLE on Test Case 15. Is there something I did not follow or is my complexity analysis flawed?
Would be really nice if someone could help!