题解 | #旋转字符串#

旋转字符串

http://www.nowcoder.com/practice/80b6bb8797644c83bc50ac761b72981c

#切片然后连接看连接后的字符串是不是和字符串B一样
class Solution:
    def solve(self , A: str, B: str) -> bool:
        # write code here
        if len(A)!=len(B):
            return False
        if len(A)==len(B):
            for i in range(len(A)):
                if A[i:]+A[0:i]==B:
                    print(A[i:]+A[0:i])
                    return True
        return False
全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务