题解 | #旋转字符串#
旋转字符串
http://www.nowcoder.com/practice/80b6bb8797644c83bc50ac761b72981c
import java.util.*;
public class Solution {
/**
* 旋转字符串
* @param A string字符串
* @param B string字符串
* @return bool布尔型
*/
public boolean solve (String A, String B) {
// write code here
int len1 = A.length();
int len2 = B.length();
if (len1 != len2) {
return false;
}
boolean bool = false;
for (int i = 0; i < len1; i++) {
String str1 = A.substring(0, i);
String str2 = A.substring(i);
String str3 = str2 + str1;
if (str3.equals(B)) {
bool = true;
break;
}
}
return bool;
}
}