akshitagit / Python

Repository for Python codes and algos. Star the repo too.
https://github.com/akshitagupta15june
MIT License
120 stars 110 forks source link

code to commit #53

Closed adityagupta26 closed 3 years ago

adityagupta26 commented 3 years ago

i will leave a code

akshitagupta15june commented 3 years ago

please specify

adityagupta26 commented 3 years ago

// CPP program to implement run length encoding

include <bits/stdc++.h>

using namespace std;

void printRLE(string str) { int n = str.length(); for (int i = 0; i < n; i++) {

    // Count occurrences of current character
    int count = 1;
    while (i < n - 1 && str[i] == str[i + 1]) {
        count++;
        i++;
    }

    // Print character and its count
    cout << str[i] << count;
}

}

int main() { string str = "wwwwaaadexxxxxxywww"; printRLE(str); return 0; }

adityagupta26 commented 3 years ago

i am not able to commit request/pull request

akshitagupta15june commented 3 years ago

ok i will add it. no worries