Skip to content

Add Run Length Encoding and Decoding [#2719] #2968

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jeetshah-410
Copy link

@jeetshah-410 jeetshah-410 commented Jul 17, 2025

This PR adds the implementation of Run Length Encoding and Decoding as part of the string compression algorithms.

Features:
encode() function: Compresses a string by converting consecutive repeated characters into a single character followed by the count.

decode() function: Expands the encoded string back to its original form.

File path:
strings/run_length_encoding.cpp

Example:
Input: "aaabbcdddd"

Encoded: "a3b2c1d4"

Decoded: "aaabbcdddd"

This implementation is simple, clear, and includes a main() function to demonstrate the functionality.

Copy link
Collaborator

@realstealthninja realstealthninja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow contribution guidelines before opening a pull request. Also make sure to follow the pull request format, This pull request does not comply. The guidelines can be found in the repository named the same.

@@ -0,0 +1,43 @@
#include <iostream>
#include <string>
using namespace std;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
using namespace std;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants