796. Rotate String
这是程序员面试金典里面的一个题目。判断B是否是A旋转得到的,只要判断B是否是A+A的字串即可。
class Solution(object):
def rotateString(self, A, B):
"""
:type A: str
:type B: str
:rtype: bool
"""
return len(A)==len(B) and B in A+A

浙公网安备 33010602011771号