diff --git a/notes/剑指 offer 题解.md b/notes/剑指 offer 题解.md index d88b6168..1162fa71 100644 --- a/notes/剑指 offer 题解.md +++ b/notes/剑指 offer 题解.md @@ -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(" ");