Your program will be fed 800 distinct numbers from of a range of 8001 to 9000. You need to store these in-memory and then print. How would you do it Thinking of an array of ints Well, that would need around (4 x 800 = 3200) bytes. Can you reduce the required memory further (by more than 20 times)
Regards
Mani

Can anyone give me an answer to this?
Tulongbaodao
Anomolous has already given the answer. You use one bit for each number between 8001 and 9000, which will take a total of 1000 bits.
The method that stores 32-bit ints would take 32*800 = 25600 bits.
Therefore the proportional space saving is 25600/1000 = 25.6. (Which is more than 20!)
Muzaffar_Ali99
Edward1
Thanks for the answer Anomolous
There is a bitarray class which does the job cleanly
By the way, I could also have boolean array if system stores bool as bits. Does bool take one bit
Regards
Mani
qrli
short can save any number in the range you specified! So using short instead of int saves you 50% of the memory 800 X 2 = 1600 bytes!
Best Regards,
Rajesh batchu