Insert temp_str into final_str ( n / 2 k ) times and add ( n % 2 k ) characters of temp_str at end
for ( var i = 0 ; i < n / ( 2 * k ) ; i ++ ) { final_str += temp_str ; } for ( var i = 0 ; i < n % ( 2 * k ) ; i ++ ) { final_str += temp_str [ i ] ; }