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
        

 

posted @ 2018-07-08 16:57  hopskin1  阅读(71)  评论(0编辑  收藏  举报