If diff [ i ] is greater print it Else print diff [ j ]
if ( diff [ i ] > diff [ j ] ) { document . write ( arr [ i ] + " " ) ; i ++ ; } else { document . write ( arr [ j ] + " " ) ; j -- ; } k -- ; } }