We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e1b634b commit ce51382Copy full SHA for ce51382
str.rotate-string.py
@@ -0,0 +1,15 @@
1
+class Solution:
2
+ """
3
+ 796. 旋转字符串
4
+ https://leetcode-cn.com/problems/rotate-string/
5
+ 给定两个字符串, A 和 B。
6
+ A 的旋转操作就是将 A 最左边的字符移动到最右边。 例如, 若 A = 'abcde',在移动一次之后结果就是'bcdea' 。如果在若干次旋转操作之后,A 能变成B,那么返回True。
7
8
+ def rotateString(self, A: str, B: str) -> bool:
9
+ if len(A) != len(B):
10
+ return False
11
+ return (B * 2).find(A) != -1
12
+
13
14
+so = Solution()
15
+print(so.rotateString('abcde', 'abced'))
0 commit comments