Printing frequency of each character just after its consecutive occurrences | C # program to print run length encoding of a string ; Counting occurrences of s [ i ] ; Driver code
using System ; class GFG { static void printRLE ( String s ) { for ( int i = 0 ; i < s . Length - 1 ; i ++ ) { int count = 1 ; while ( s [ i ] == s [ i + 1 ] ) { i ++ ; count ++ ; if ( i + 1 == s . Length ) break ; } Console . Write ( s [ i ] + " " + count + " ▁ " ) ; } Console . WriteLine ( ) ; } public static void Main ( String [ ] args ) { printRLE ( " GeeeEEKKKss " ) ; printRLE ( " ccccOddEEE " ) ; } }