text: Traverse the array . If arr [ i ] is non - zero , then swap the element at index ' count ' with the element at index ' i '
code: for ( let i = 0 ; i < n ; i ++ ) if ( arr [ i ] != 0 ) { temp = arr [ count ] ; arr [ count ] = arr [ i ] ; arr [ i ] = temp ; count = count + 1 ; } }