I was going through this question to better understand which input/output scheme would be more time-space efficient.
However all my solutions had an unusually high space usage of around 177+ MB, so was a little puzzled.
I looked over some solutions and gave a shot by putting in the solution of someone [Credit goes to dfedotov] who has done it in the same language [JAVA].
But the solutions again confused me as the difference in the same code was huge [JAVA]:
1641711 [My solution] 0.29 secs 177.3M
991526 [Original solution] 0.30 secs 0M
Can anybody help me to understand why there is such a huge difference for the same language?