-
-
Notifications
You must be signed in to change notification settings - Fork 298
/
Copy path796.cpp
41 lines (41 loc) · 1.13 KB
/
796.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
__________________________________________________________________________________________________
sample 4 ms submission
class Solution {
public:
bool rotateString(string A, string B) {
return A.size() == B.size() && (
A == B || (A + A).find(B) != string::npos
);
}
};
__________________________________________________________________________________________________
sample 8308 kb submission
class Solution {
public:
bool rotateString(string A, string B) {
if(A.size()!=B.size()){
return false;
}
bool flag=false;
int tmp = 0;
int size = A.size();
if(size==0){
flag=true;
}
for(int i=0; i<size; i++){
int flag2 = 1;
for(int j=0; j<size; j++){
tmp = (i+j)%size;
if(A[tmp]!=B[j]){
flag2=0;
}
}
if(flag2==1){
flag=true;
return flag;
}
}
return flag;
}
};
__________________________________________________________________________________________________