题解 | #旋转字符串#
旋转字符串
https://www.nowcoder.com/practice/80b6bb8797644c83bc50ac761b72981c
class Solution {
public:
bool solve(string A, string B) {
// write code here
if(A == B) return true;
int an = A.size();
int bn = B.size();
if(bn != an) return false;
for(int i = 1; i < an; i++){
string temp1 = A.substr(0,i);
string temp2 = A.substr(i, an);
string temp = temp2 + temp1;
if(temp == B) return true;
}
return false;
}
};
文远知行公司福利 544人发布
查看2道真题和解析