What is a faster Java IO to avoid TLE?

I’ve tried using Scanner, always gives me TLE and when I try bufferedReader and StringTokenizer I’m always getting en error. How do I put my input ?

@lousybrick,
Are you sure your code is optimized to the best possible complexity? If not, please share your code as well.

For a faster IO, you can use fastreader.

I’ve used fastReader too but i was getting an error related to Stringtokenizer. In terms of algorithm my answer is correct because it worked when i put my values in the code.

@lousybrick,
Please share your code. https://ide.codingblocks.com/

@lousybrick,
Save the code on the ide and share with me the link

https://ide.codingblocks.com/s/208648 here’s the code.

@lousybrick,

You should be using recursion here. Just take a string input and pass that as argument into your recursive function along with an empty string.

The base condition will be when length of input string is 0. In the base condition print your output string and return.

Now check what your next digit maps to and append that to your output string and call the recursive function with substring starting from 1 of input string and output string as arguments.

Now check for double digits and repeat the above process.

That should be the approach and your code will pass the test cases

@lousybrick,
Also, right now its actually more of a nullpointer exception which is giving you a TLE in this line: arr[i] = Integer.parseInt(br.readLine()); Rather than the code logic.

how do i solve this ? the only issue im having right now is taking the user input. What approach do i take ?

@lousybrick,
Take input as string only and use string/stringbuilder to store your answer.

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.