If the characters are the same , then perform the swap operation as illustrated
if ( check [ mid ] == s [ mid ] ) { for ( let i = 0 ; i < s . length ; i ++ ) { if ( check [ i ] != s [ mid ] && s [ i ] != s [ mid ] ) { s = swap ( s , i , mid ) break ; } } } }