How to handle TLE in Java and C++?

Please tell me How to handle TLE in Java and C++
Thank you in advance

@iamtheone_kool - You can check this out - Why do I get a Time Limit Exceeded? - #2 by admin.
If you are getting TLE → in most cases you need to reduce the complexity of your code. For example → you are running a loop within a loop → but the constraints mean that you will have to find an approach where a single loop suffices. This is problem specific → check out ‘Other Users’ submissions’ to understand how other users got an AC.

This post was flagged by the community and is temporarily hidden.

hmm, thanks, this post by the admin was great thanks :slight_smile:

there are some things to consider when using Java.

Input reading with standard libraries can be so slow that it may cause a TLE. Using some kind of custom Scanner class is a must.

sorting arrays of primitive types will be done viá Quicksort in Java. Quicksort has a worst case of O(n²), this is too slow for many problems. Forcing Java to use Mergesort instead is another must.