#embody <bits/stdc++.h>
utilizing
namespace
std;
string leftrotate(string& s,
int
d)
{
reverse(s.start(), s.start() + d);
reverse(s.start() + d, s.finish());
reverse(s.start(), s.finish());
return
s;
}
int
MinimumRotations(string A, string B)
{
int
rotations = 0;
int
len = A.size();
int
B_index = 0;
for
(
int
i = 0; i < len; i++) {
if
(A[0] == B[B_index]) {
A.erase(A.start() + 0);
B_index++;
}
if
(A[0] != B[B_index]) {
A = leftrotate(A, 1);
rotations++;
i = 0;
}
}
return
rotations;
}
int
fundamental()
{
string A =
"geek"
;
string B =
"geek"
;
cout << MinimumRotations(A, B) << endl;
string A2 =
"abcd"
;
string B2 =
"bcda"
;
cout << MinimumRotations(A2, B2) << endl;
string A3 =
"agef"
;
string B3 =
"afge"
;
cout << MinimumRotations(A3, B3) << endl;
return
0;
}