leetcode 796. Rotate String

class Solution {
public:
    bool rotateString(string A, string B) {
     
        int l1 = A.length();
        int l2 = B.length();
        if(l1!=l2)return false;
        if(l1==0)return true;
        int j;
        for(int i=0;i<l1;i++)
        {
            for(j=0;j<l2;j++)
            {
                if(A[j]!=B[(j+i)%l1])break;
                else continue;
            }
            if(j==l2)return true;
        }
        return false;
    }
};

猜你喜欢

转载自blog.csdn.net/wangchy29/article/details/89302443
今日推荐