The sort() function has asymptotic time complexity of O(N*log N). For randomly generated numbers this is the best that we can do (due to the lower bound for any comparison based sorting algorithms).
Note :: The functions/methods implemented in STL are generic and optimised.
For your question, if it is giving TLE, there might be some other better approach to solve it.
More specifically you can post the link to your question so that one could tell if it is needed or there is some better way of doing it
Why do you think your code is more time efficient? It’s using std::sort too, so both are O(n log n). And do explain the purpose of euler_flip() function.
There’s always a possibility in any problem we need not sort the whole array or string, So instead of sorting whole you can sort to a particular indices.it’s more time efficient. Please read the full answer I wrote clearly “I can give only suggestions as I don’t know about your problem.” Now please tell me how it’s misleading.
@meoow Did I misuse this community platform. I don’t think so. Please avoid reporting directly any answers. Instead a down vote is enough. I am not abusing anyone. I have followed the codechef code of conduct every time. Reporting can cause suspension of my codechef account, Ok I understand you are not satisfied with this answer but It’s still accepted answer.
@only4 your answer being accepted is precisely what bothers me. You literally claim that your std::sort() is faster than someone else’s std::sort(). It is misleading and I have reported it to be so. Besides, this is not the first time you have given such an answer and I have politely asked you not to before.
Before answering a question I would suggest you consider whether your answer will actually help the person who asked the question or make him more confused.