From 785f48ba52e2427456a8c419c9aeeaa5b3699aca Mon Sep 17 00:00:00 2001 From: YiliaZhang <532104074@qq.com> Date: Mon, 27 Aug 2018 23:21:40 +0800 Subject: [PATCH] =?UTF-8?q?Update=20=E5=89=91=E6=8C=87=20offer=20=E9=A2=98?= =?UTF-8?q?=E8=A7=A3.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 5. 替换空格 在for (int i = 0; i < str.length( ); i++)中,str还在一直append,for循环出不去,最终会报OOM --- notes/剑指 offer 题解.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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(" ");