The overall action being done here is string manipulation, with spaces being overwritten with the assigned characters '%20'. The text's hints suggest startiung the cretaion of the updated string from the end of it to avoid overwriting important characters. In addition, index management becomes much easier since we are effectively replacing a single character with three characters in this problem. Creating the new string from the start would mean having to recalculate the index of the next space after each manipulation.
The strategy to solving this begins in counting the spaces that exist within the 'true length' paramenter. So in the case of "Mr John Smith ", starting with the 'M' as 1, we can count each space twelve more times until we reach 13, which is the character 't' in the example. Within that subset, there exist two spaces. Since we are replacing the spaces with '%20', we will want to update the new string's length to accomodate the new additions. So for each space we add two hence the line int newLength = trueLength + spaceCount * 2.
The rest of the code will generate the new string starting from the end of it, printing the original string character by character until it finds a space.