Update 剑指 offer 题解.md
5. 替换空格 在for (int i = 0; i < str.length( ); i++)中,str还在一直append,for循环出不去,最终会报OOM
This commit is contained in:
parent
9e98742585
commit
785f48ba52
|
@ -230,7 +230,7 @@ Output:
|
|||
```java
|
||||
public String replaceSpace(StringBuffer str) {
|
||||
int P1 = str.length() - 1;
|
||||
for (int i = 0; i < str.length(); i++)
|
||||
for (int i = 0; i < P1+1; i++)
|
||||
if (str.charAt(i) == ' ')
|
||||
str.append(" ");
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user