I made a comment on this is another question, which was asked by someone else. This seems to be referring to my comment, so I'll explain what I meant. What I was suggesting was:
struct interval_node {
int index;
struct interval_node* next;
}
where index stores all the points where the bit "flips". This is a huge memory advantage if you have something like 11111111111100000000000
, because it only needs to store the fact that the first bit is 1 (outside of the struct somewhere), as well as that the bit flips in the 12th index (being 0-based), rather than storing each individual bit itself. This can scale to 100,000 bits without eating up as much memory as long as the sequence doesn't have a ton of things like
1010101010101010101010101010101010101010101010
Because the it flips at every bit.