To check whether the character is inserted earlier in the encoded string or not
if ( arr [ key [ i ] - 65 ] == 0 ) { encoded += key [ i ] ; arr [ key [ i ] - 65 ] = 1 ; } } else if ( key [ i ] >= ' a ' && key [ i ] <= ' z ' ) { if ( arr [ key [ i ] - 97 ] == 0 ) { encoded += key [ i ] - 32 ; arr [ key [ i ] - 97 ] = 1 ; } } }