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 173ff1c

Browse files
committed
Time: 31 ms (80.30%) | Memory: 16.5 MB (19.68%) - LeetSync
1 parent c95612f commit 173ff1c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

‎812-rotate-string/rotate-string.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Solution:
2+
def rotateString(self, s: str, goal: str) -> bool:
3+
if len(s) != len(goal):
4+
return False
5+
start = goal[0]
6+
if start not in s:
7+
return False
8+
9+
k = [i for i, j in enumerate(s) if j == start]
10+
11+
12+
13+
for st in k:
14+
res = s[st:] + s[:st]
15+
print(res)
16+
if res == goal:
17+
return True
18+
return False

0 commit comments

Comments
(0)

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