If element is present then swapped
if ( ( int ) sortarr [ i ] == ( int ) arr [ j ] ) { int tmp = ( int ) arr [ i ] ; arr [ i ] = ( int ) arr [ j ] ; arr [ j ] = tmp ; flag = 1 ; break ; } if ( j + k >= n ) { break ; } }