I have a large array with a range of integers that are mostly continuous, eg 1-100, 110-160, etc. All integers are positive. What would be the best algorithm to compress thi
I'd combine the answers given by CesarB and Fernando Miguélez.
First, store the differences between each value and the previous one. As CesarB pointed out, this will give you a sequence of mostly ones.
Then, use a Run Length Encoding compression algorithm on this sequence. It will compress very nicely due to the large number of repeated values.