Hi, lets say i have a number like 9152 ...and its to be expanded as such : 11111111122222

(thats 9 ones and 5 twos)

so .. if i want to expand any given number ... the obvious quick solution is something like this..

but in this solution ... we do ret.length() string concats , I want to assume that this is horrible for inputs such as 9999999999.Code:string expand(string& input) { string ret=""; for(int i=0;i<input.length();i+=2) { int expand_amount = input[i] - '0'; for(int j=0;j < expand_amount; ++j) ret+=input[i+1]; } return ret; }

Anyone have a solution to making this a bit more .....clever?

(probably avoiding string concats all together)