How to reduce time limit?

This is a very general question. I have solved the first problem in April Challenge, and got “1.24 seconds” as my time, which puts it in the 52nd page. However, there are 44 pages of people who solved it in 0.00 seconds.

Any general tip on how to reduce time?? (I am using Java)

In java use the fast IO methods.
For Input use BufferedReader() and not Scanner() because it is extremely slow.
For Output use PrintWriter() to get lower running time on Codechef().
The other optimizations are in general standard for all programming languages.
Note : But note that the time of Java that you would observe will always be more than C/C++ for codes with same complexity and algorithm.

1 Like

try using faster io methods!!