-
Notifications
You must be signed in to change notification settings - Fork 20k
[FEATURE REQUEST] String Compression #3911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Is it run length encoding? If so, feel free to implement it |
My current code returns the encoded length if you want the encoded string I can modify accordingly. |
Yes, please. The purpose of any encoding is to encode the text. |
I modified my algorithm that returns the encoded string and created a pull request for this issue, can you please check? |
@siriak I made the necessary changes as u told on the PR, the changes include:
|
@siriak can you please check, I have made the necessary changes in my PR? |
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!
The text was updated successfully, but these errors were encountered: