what is wrong in my code
Balanced paranthesis
#include #include using namespace std; bool balancedparanthesis(char *s){ stack st; for(int i=0;s[i]!=β\0β;i++){ char ch = s[i]; if(ch == β(β){ st.push(ch); } else if(ch==β)β){ if(st.empty() or st.top()!=β(β ){ return false; } st.pop(); } } return st.empty(); } int main() { char s[10000]; cin>>s; balancedparanthesis(s); if(balancedparanthesis){ cout<<βYesβ<<endl; } else{ cout<<βNoβ; } return 0; }
hi @abhinavssr2003_eab0717682969e5c,
char s[10000];
cin>>s;
if(balancedparanthesis(s)){ // (s) use it as a function inside
cout<<"Yes"<<endl;
}
I hope Iβve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.