I was working on string decoding. Given a decoded string Q need to find the original string P. The equation for original string is given as P[i] = Q[i-1] - P[i-1] - P[i-2] except for P[0] and P[n]. If I consider P and Q as std::string, I couldnt assign value for P at each position. For example,