Checking the given condition
if ( s [ i ] != s [ j ] && check [ i ] != s [ j ] && check [ j ] != s [ i ] ) { char temp = s [ i ] ; s = s . Substring ( 0 , i ) + s [ j ] + s . Substring ( i + 1 ) ; s = s . Substring ( 0 , j ) + temp + s . Substring ( j + 1 ) ; i ++ ; j = s . Length - 1 ; } else { j -- ; } }