class Solution {
public String replaceSpaces(StringBuffer str) {
if(str == null) {
return null;
}
String result = “”;
for(int i = 0;i < str.length(); i++) {
char ch = str.charAt(i);
if(ch == ‘ ‘) {
result += “%20”;
continue;
}
result += ch;
}
return result;
}
}