Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Contact us
Hide Buttons

String compression using the counts of repeated characters.

Input : A string // aaaabbc
Output : A string // a4b2c1

Logic :

  • Iterate over the string
  • Compare the current and next characters.
  • If both characters are not same,
    • Then increment the count by 1 and do string concatenation.

Solution :

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *