题目:
字符串轮转。给定两个字符串s1和s2,请编写代码检查s2是否为s1旋转而成(比如,waterbottle是erbottlewat旋转后的字符串)。
示例1:
输入:s1 = "waterbottle", s2 = "erbottlewat"
输出:True
分析: 首先判断两个字符串长度是否相等,相等再将s1拼接一份s1,判断s2是否是s1的字串
def isFlipedString(self, s1: str, s2: str) -> bool:
if len(s1) != len(s2):
return False
new_s1 = s1 + s1
if s2 in new_s1:
return True
return False