File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
CrackingTheCodingInterview/Chapter1ArraysAndStrings Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change 1
- // Write a method to replace all spaces in a string with '%20.' You may assum ethat the string
2
- // has sufficient space at th eend of the string to hold the additional characters, and that you
1
+ // Write a method to replace all spaces in a string with '%20.' You may assume that the string
2
+ // has sufficient space at the end of the string to hold the additional characters, and that you
3
3
// are given the "true" length of the string. (Note: if implementing in Java, please use a characters
4
4
// array so that you can perform this operation in place)
5
5
6
6
public class ReplaceSpaces {
7
7
public void replaceSpaces (char [] str , int length ) {
8
- int spaceCount = 0 , newLength ; i ;
8
+ int spaceCount = 0 , newLength ;
9
9
for (int i = 0 ; i < length ; i ++) {
10
10
if (str [i ] == ' ' ) {
11
11
spaceCount ++;
You can’t perform that action at this time.
0 commit comments