Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

Vrutik_2809's blog

By Vrutik_2809, history, 2 months ago, In English

I was solving this problem. Although my solution is correct, i got TLE due to Java. My solution can be found here. But when i submitted the same solution in C++, it got accepted.

Can someone please help me out with how i can improve printing time in Java?

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

you can use StringBuilder like this

  • »
    »
    2 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Thanks for the help. So, in general, we should prefer default printing, and if we face this type of problem, we can try this approach. Is there any way to figure out priorly which method we should prefer? Because this is the first time I have encountered this type of problem

    • »
      »
      »
      2 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      best way in my opinion is just to use PrintWriter in general (check below comment for sample sol with it), you can just include it in a template just like you already have FastReader in it, so it should be fine

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

You can use PrintWriter