class Solution {
public:
string replaceSpaces(string S, int length) {
string temp;
for(int i = 0; i < length; i++)
{
temp += S[i];
}
string res;
for(int i = 0; i < temp.size(); i++)
{
if(temp[i] == ' ')
{
res += "%20";
}
else
{
res += temp[i];
}
}
return res;
}
};