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!
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!
Thank you Raksha! :)