I was solving one question based on printing pattern in which I had to perform lot of output stuff.I used to approach for this which are as follows:-
I used System.out.println() statement for printing every single character on the screen.
In this approach I appended every single character to a StringBuilder and then output that on screen using same System.out.println() statement.
When I used first approach I got TLE then after seeing someone else’s solution I used the second approach and got sufficiently higher performance, which not only pulled me out of TLE but also brought down my execution to the great extent.
Can anyone explain me the reason why there is such a performance difference in the two approaches.