I'm having difficulty using RLE for character sequences.
For example, I can do RLE encoding in strings like
"ASSSAAAEERRRRRRRR"
which will be converted to:
"A1S3A3E2R8".
But I would like to do RLE for strings like
"XXXYYYYY(1ADEFC)(EDCADD)(1ADEFC)(1ADEFC)(1ADEFC)"
which will be converted to:
"X3Y5(1ADEFC)1(EDCADD)1(1ADEFC)3"
Is there any way to achieve this? This task becomes a little easier because long strings always appear in brackets. Could you give advice to do this in C ++?
If there is a better way to preserve values ββthan using parentheses, it would also be great if you recommend me.
source share