Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 633293b

Browse files
添加解题方法
1 parent e41471f commit 633293b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

‎problems/剑指Offer58-II.左旋转字符串.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,18 @@ class Solution:
194194

195195
```
196196

197+
```python 3
198+
# 方法五:另类的切片方法
199+
class Solution:
200+
def reverseLeftWords(self, s: str, n: int) -> str:
201+
n = len(s)
202+
s = s + s
203+
return s[k : n+k]
204+
205+
# 时间复杂度:O(n)
206+
# 空间复杂度:O(n)
207+
```
208+
197209
Go:
198210

199211
```go

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /