How to compress strings like “aaabbbc” to “a3b3c” and decompress the same, without using extra memory during processing, primarily in C and also in Java?
How to compress strings like aaabbbc to a3b3c and decompress the same, without using
Share
A simple reverse scan does provide a (seemingly) good solution to the encoding part at least. I am doing one scan from right to left and overwriting the portions of the string with the occurrence count.
Input : aaaaaaaaaaaabbbfffffffffffffffqqqqqqqqqqqqqqqqqqccccpoii
Output: a12b3f15q18c4poi2