Given an input string, write a function that returns the Run Length Encoded string for the input string.
For example, if the input string is “wwwwaaadexxxxxx”, then the function should return “w4a3d1e1x6”.
a) Pick the first character from source string.
b) Append the picked character to the destination string.
c) Count the number of subsequent occurrences of the picked character and append the count to destination string.
d) Pick the next character and repeat steps b) c) and d) if end of string is NOT reached.
Time Complexity: O(n)
Please write comments if you find the above code/algorithm incorrect, or find better ways to solve the same problem.
- Run Length Encoding in Python
- Encoding a word into Pig Latin
- Check if an encoding represents a unique binary string
- Nth Even length Palindrome
- Sum of first K even-length Palindrome numbers
- Sub-strings of length K containing same character
- Repeated subsequence of length 2 or more
- Length Of Last Word in a String
- Maximum length of segments of 0's and 1's
- LCS formed by consecutive segments of at least length K
- Check if all the palindromic sub-strings are of odd length
- Program for length of a string using recursion
- Find words which are greater than given length k
- Maximum length substring having all same characters after k changes
- Maximum length subsequence possible of the form R^N K^N