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 ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] != 0 ) swap ( arr [ count ++ ] , arr [ i ] ) ; }