From 42d72e2a313cc0409b183923c1d3d8d9bcc38fdf Mon Sep 17 00:00:00 2001 From: Flow-sandyu <72751523+Flow-sandyu@users.noreply.github.com> Date: Mon, 3 Oct 2022 18:14:34 +0800 Subject: [PATCH] =?UTF-8?q?update=EF=BC=9A0151.=E7=BF=BB=E8=BD=AC=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E4=B8=B2=E9=87=8C=E7=9A=84=E5=8D=95=E8=AF=8D.md=20jav?= =?UTF-8?q?a=20=E7=89=88=E6=9C=AC=EF=BC=8C=E5=A2=9E=E5=8A=A0=E8=A7=A3?= =?UTF-8?q?=E6=B3=95=E5=9B=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 时间复杂度 O(n) 参考卡哥 c++ 代码的实现:先移除多余空格,再将整个字符串反转,最后把单词逐个反转 有别于解法一 :没有用 StringBuilder 实现,而是对 String 的 char[] 数组操作来实现以上三个步骤 --- problems/0151.翻转字符串里的单词.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/problems/0151.翻转字符串里的单词.md b/problems/0151.翻转字符串里的单词.md index 5a8f8094..be35c2f2 100644 --- a/problems/0151.翻转字符串里的单词.md +++ b/problems/0151.翻转字符串里的单词.md @@ -363,7 +363,8 @@ class Solution { ```java /* * 解法四:时间复杂度 O(n) - * 参考卡哥 c++ 代码的实现:先移除多余空格,再将整个字符串反转,最后把单词逐个反转 + * 参考卡哥 c++ 代码的三步骤:先移除多余空格,再将整个字符串反转,最后把单词逐个反转 + * 有别于解法一 :没有用 StringBuilder 实现,而是对 String 的 char[] 数组操作来实现以上三个步骤 */ class Solution { //用 char[] 来实现 String 的 removeExtraSpaces,reverse 操作