Decode a given string by removing duplicate occurrences | C # program for the above approach ; Function to count the appearances of each character ; If the character is lower case ; If the character is uppercase ; If the character is a punctuation mark ; Function to decode the given encoded string ; Iterate the given string str ; Find the index of the next character to be printed ; Driver Code
using System ; using System . Collections . Generic ; class GFG { static int findRepitition ( char a ) { if ( a <= ' z ' && a >= ' a ' ) { return ( int ) a - 97 ; } else if ( a <= ' Z ' && a >= ' A ' ) { return ( int ) a - 65 ; } return 0 ; } static void decodeString ( string str ) { string output = " " ; for ( int i = 0 ; i < str . Length ; i ++ ) { output += str [ i ] ; i += findRepitition ( str [ i ] ) ; } Console . Write ( " Decrypted ▁ code ▁ is ▁ { " + output + " } " ) ; } public static void Main ( ) { string str = " abbbb ▁ acccdddd " ; decodeString ( str ) ; } }