I'm preparing to go to a computer science contest by completing problems from past contests. Most of them are pretty easy, but this one is bugging me...it seems simple but I'm just not being able to do it.
If you have a string of ones and zeros:
100111010001111100101010
What would be the code to take that as an input and then output this:
1:1 2:0 3:1 1:0 1:1 3:0 5:1 2:0 1:1 1:0 1:1 1:0
Where the digit to the left of each colon is the number of times the digit after the colon appears.
So, another example...inputting:
1100011
Would output:
2:1 3:0 2:1
According to the problem this is similar to the algorithm used to compress fax transmissions.
An answer in java would be best, but all I'm really looking for is pseudocode or even thoughts on how to do it.
Thanks in advance.