-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path87.cpp
More file actions
executable file
·42 lines (42 loc) · 1.26 KB
/
87.cpp
File metadata and controls
executable file
·42 lines (42 loc) · 1.26 KB
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
42
#include <iostream>
#include <string>
using namespace std;
class Solution {
public:
bool isScramble(string s1, string s2) {
if (s1.size() != s2.size())
return false;
if (s1.size() == 0)
return true;
bool stackflag = false;
string stack1= "";
string stack2= "";
int index1 = 0;
while (index1 < s1.size()){
cout<<index1<<endl;
if (s1[index1] != s2[index1] && stackflag){
stack1 = s1[index1];
stack2 = s2[index1];
stackflag = false;
index1++;
}else if (stackflag == false){
if (stack1[0] == s2[index1]){
//compare
stack1 += s1[index1];
stack2 += s2[index1];
reverse(stack1.begin(), stack1.end());
if (stack1 != stack2) return false;
stackflag = true;
stack1 = "";
stack2 = "";
index1++;
}else{
stack1 += s1[index1];
stack2 += s2[index1];
index1++;
}
}else index1++;
}
return stackflag;
}
};