题解 | #旋转字符串#
旋转字符串
http://www.nowcoder.com/practice/80b6bb8797644c83bc50ac761b72981c
class Solution {
public:
/**
* 旋转字符串
* @param A string字符串
* @param B string字符串
* @return bool布尔型
*/
bool solve(string A, string B) {
// write code here
if(A.size() != B.size())
return false;
int l = 0;
int f = 0;
for(; f < A.size(); f++) {
if(A[f] == B[0])
break;
}
for(; l < f; l++) {
if(A[l] == B[f + l])
continue;
else
return false;
}
if(l == f)
return true;
else
return false;
}
};