Skip to content

Commit 9c88a26

Browse files
committedDec 20, 2020
perf: rotate-string
1 parent ce51382 commit 9c88a26

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed
 

‎str.rotate-string.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ class Solution:
66
A 的旋转操作就是将 A 最左边的字符移动到最右边。 例如, 若 A = 'abcde',在移动一次之后结果就是'bcdea' 。如果在若干次旋转操作之后,A 能变成B,那么返回True。
77
"""
88
def rotateString(self, A: str, B: str) -> bool:
9-
if len(A) != len(B):
10-
return False
11-
return (B * 2).find(A) != -1
9+
return len(A) == len(B) and A in (B * 2)
1210

1311

1412
so = Solution()

0 commit comments

Comments
 (0)
Please sign in to comment.