How to get rid of Java TLE problem?
It happens many times that you have written correct Java code with as much optimization as needed according to the constraints. But, you get TLE (Time Limit Exceeded). This happens due to the time taken by Java to take input and write output using Scanner class which is slow as compared to BufferedReader and StringBuffer class.
Most of the cases the TLE is due to the algorithm used while compiling and in most f the time it is due o slow input and output. TLE can be solved by using fast input in java such as BufferedReader and StringBuffer. It takes the input in half a second compared to other input.