Shifting the max . The equal condition happens if we shifted the max to arr [ min_i ] in the previous swap .
if ( arr [ min_i ] == max ) swap ( arr [ j ] , arr [ min_i ] ) ; else swap ( arr [ j ] , arr [ max_i ] ) ; } }