int main(){
string s;
cin>>s;
stack st;
int counter=0;
int max=0;
for(int i=0;i<s.length();i++){
if(s[i]==’(’){
st.push(s[i]);
}
else{
if(!st.empty() && st.top()==’(’){
st.pop();
counter=counter+2;
}else{
if(counter>max){
max=counter;
}
counter=0;
}
}
}
cout<<counter;
return 0;
}
This is giving wrong answer.
Also not able to unlock test cases.