It’s not like ACed solution is passing just by a margin, but rather it’s taking half of the time than TLEd solution.
The difference in both solutions is only at line 125 where I have to output my final answer.
In AC Solution : list.forEach( x -> pn(x)) // pn is just used for printing
This is java8 style of iterating over collection
TLE Solution : for (String x : list) pn(x);
This is trivial for each style loop.
I searched it on the internet for the performance difference among two styles of the loop but was not able to get satisfactory answers, many sources have mentioned both are equal in terms of performance.
Can somebody help me to understand this behavior?