해맑은욱 2023. 8. 8. 01:18
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int solution(string A, string B) {
    int answer = 0;
    
    if(A == B)
        return 0;
    
    int i = 0;
    while(i < A.size())
    {
        // 1만큼 시계 반대방향으로 이동
        rotate(A.begin(), A.begin() + A.size() - 1, A.end());
        i++;
        
        if(A == B)
            return i;        
    }
    
    return -1;
}

// 발상의 전환이 필요한 코드..awesome..
int solution(string A, string B)
{
    B += B;
    return B.find(A);
}