Storing the results of test Cases

Is it a good practice to store the results of various test cases in a array then giving the output so that the output becomes fast…

The constraints being less which ensure that the results could be stored in a array
for eg
storing all the prime numbers in a array and then outputting the required number of prime numbers between 2 numbers

Sorry, is it a question?

yes it is a question !!! i just want to ask that is it a good practice storing the results of all the possible test case ???

Hi,

You seem to be confused with your own question…

There are two possible angles from which one can answer this:

a) Can I store results on an array, as in, pre-compute values so subsequent calculations are performed faster?

OR

b) Can I store all output on an array and print entire array afterwards?

Answer to both questions is yes you can :slight_smile:

However, for question a) you must be aware that sometimes the source code size limit might not allow you to store huge arrays directly “hard coded” in your code.

If that’s the case, than possibly using pre-processing might not be the way to go :slight_smile:

Best,

Bruno

1 Like
//