If current character S [ i ] is different from S [ j ]
if ( S [ j ] != S [ i ] ) { j ++ ; S [ j ] = S [ i ] ; } } char [ ] A = new char [ j + 1 ] ; Array . Copy ( S , 0 , A , 0 , j + 1 ) ; Console . WriteLine ( A ) ; }