From 2393f86448a3ae64514bfc4dea3ab0bb2d5fc8f0 Mon Sep 17 00:00:00 2001 From: hbm666 <1208415748@qq.com> Date: Sun, 27 Aug 2023 11:17:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/剑指Offer58-II.左旋转字符串.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/problems/剑指Offer58-II.左旋转字符串.md b/problems/剑指Offer58-II.左旋转字符串.md index a3fb7ab3..f58135eb 100644 --- a/problems/剑指Offer58-II.左旋转字符串.md +++ b/problems/剑指Offer58-II.左旋转字符串.md @@ -120,8 +120,9 @@ class Solution { ``` ```java -//解法二:空间复杂度:O(1)。用原始数组来进行反转操作 -//思路为:先整个字符串反转,再反转前面的,最后反转后面 n 个 +// 解法二 +// 空间复杂度:O(n)。String 的 toCharArray() 方法底层会 new 一个和原字符串相同大小的 char 数组 +// 思路为:先整个字符串反转,再反转前面的,最后反转后面 n 个 class Solution { public String reverseLeftWords(String s, int n) { char[] chars = s.toCharArray(); @@ -418,3 +419,4 @@ impl Solution { +