Reading input all together or in steps?
Posted
by
nischayn22
on Programmers
See other posts from Programmers
or by nischayn22
Published on 2012-06-03T08:30:03Z
Indexed on
2012/06/03
10:47 UTC
Read the original article
Hit count: 225
For many programming quizzes we are given a bunch of input lines and we have to process each input , do some computation and output the result.
My question is what is the best way to optimize the runtime of the solution ?
- Read all input, store it (in array or something) ,compute result for all of them, finally output it all together.
or 2. Read one input, compute the result, output the result and so on for each input given.
© Programmers or respective owner