Run Length Encoding | C # program to implement run length encoding ; Count occurrences of current character ; Print character and its count ; Driver code
using System ; class GFG { public class RunLength_Encoding { public static void printRLE ( String str ) { int n = str . Length ; for ( int i = 0 ; i < n ; i ++ ) { int count = 1 ; while ( i < n - 1 && str [ i ] == str [ i + 1 ] ) { count ++ ; i ++ ; } Console . Write ( str [ i ] ) ; Console . Write ( count ) ; } } public static void Main ( String [ ] args ) { String str = " wwwwaaadexxxxxxywww " ; printRLE ( str ) ; } } }