int Solution::solve(string A, string B) {
stackst;
string str="";
for(int i=0;i<A.length();i++){
if(A[i]!=’)’){
st.push(A[i]);
}
else{
while(st.top()!=’(’){
str=str+st.top();
st.pop();
}
st.pop();
if(!st.empty() && st.top()==’-’){
for(int j=0;j<str.length();j++){
if(str[j]>=‘a’ || str[j]<=‘z’)
continue;
else{
if(str[j]==’+’)
str[j]=’-’;
else
str[j]=’+’;
}
}
}
}
}
while(!st.empty()){
str = str+ st.top();
st.pop();
}
reverse(str.begin(),str.end());
string str1="";
for(int i=0;i<B.length();i++){
if(B[i]!=')'){
st.push(B[i]);
}
else{
while(st.top()!='('){
str1=str1+st.top();
st.pop();
}
st.pop();
if(!st.empty() && st.top()=='-'){
for(int j=0;j<str1.length();j++){
if(str1[j]>='a' || str1[j]<='z')
continue;
else{
if(str1[j]=='+')
str1[j]='-';
else
str1[j]='+';
}
}
}
}
}
while(!st.empty()){
str1 = str1+ st.top();
st.pop();
}
reverse(str1.begin(),str1.end());
for(int i=0;i<str.length();i++)
{
if(str1[i]!=str[i])
return 0;
}
return 1;
}.