読者です 読者をやめる 読者になる 読者になる

Replace all space in a string with '%20'

Cracking The Coding Interview

Problem

Write a method to replace all space in a string with '%2d'. You may assume that the string has sufficient space at the end of the string to hold the additional character, and that you are given the true length of the string.

[example]

ab_cd → ab%20cd

How to Solve

By editing the string starting from end to head, It is not necessary to consider of overwriting.

Source Code