From 633293b509052780afc83b23c07a4ad79ba18156 Mon Sep 17 00:00:00 2001 From: Logen <47022821+Logenleedev@users.noreply.github.com> Date: Tue, 14 Feb 2023 19:23:52 -0600 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=A7=A3=E9=A2=98=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/剑指Offer58-II.左旋转字符串.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/problems/剑指Offer58-II.左旋转字符串.md b/problems/剑指Offer58-II.左旋转字符串.md index 1b619ffb..49480abf 100644 --- a/problems/剑指Offer58-II.左旋转字符串.md +++ b/problems/剑指Offer58-II.左旋转字符串.md @@ -194,6 +194,18 @@ class Solution: ``` +```python 3 +# 方法五:另类的切片方法 +class Solution: + def reverseLeftWords(self, s: str, n: int) -> str: + n = len(s) + s = s + s + return s[k : n+k] + +# 时间复杂度:O(n) +# 空间复杂度:O(n) +``` + Go: ```go