DEV Community

Discussion on: Master Java: Basics. 🚀

Collapse
 
parthgo73533565 profile image
Parth Goyal

I know it's early to ask but can you tell me how to create a user defined 'FastReader class'.
I want to use it because Scanner class takes a lot of time resulting in time limit exceed in competitive programming and BufferReader class is also never recommended in competitive programming because of its complexity.

Collapse
 
rakshakannu profile image
Raksha Kannusami

Hey Parth! When it comes to competitive programming, if you are ending up with TLE, try to optimize the time complexity by changing the approach of solving the problem, but if you are not able to do that, then you can use the FastReader class, I will be writing the article on it soon. Meanwhile do refer to the article given by Mohamed given in the comments!

PS - it is always better to use Scanner class since fast I/O methods make your program very lengthy. And these type of questions are really rare and won't be asked in interviews as such!

Collapse
 
parthgo73533565 profile image
Parth Goyal

Thank you Raksha! :)

Collapse
 
mohamedmoustafanuig profile image
Mohamed Moustafa

While the author replies, check out the geeks-for-geeks post about this: geeksforgeeks.org/fast-io-in-java-...

Collapse
 
parthgo73533565 profile image
Parth Goyal

Thanks Mohamed Moustafa :)