Skip to content

[FEATURE REQUEST] String Compression #3911

Closed
@Swarga-codes

Description

@Swarga-codes

What would you like to Propose?

I would like to add the string compression algorithm that compresses and returns the size of a string as per the example given below:
Input:
Here, we take a string of characters,
char[] chars = ["a","a","b","b","c","c","c"]

Output: 6

Explanation: The groups are "aa", "bb", and "ccc". This compresses to "a2b2c3", which has a size of 6. Also, if any character has a single occurence we don't write it as "a1" or "b1" rather we just add that character to the resulting string.

Issue details

I was going through the strings folder, and didn't find this algorithm and wanted to contribute this algorithm to this repo.

Additional Information

I was struggling to solve the question based on this on leetcode and finally managed to solve it on my own, that is, a leetcode accepted solution and would love to share this solution and add it to the repo. Thank you!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions