Test case 2 not pasing

i have included all the mentioned cases in comments, however when i include those comments the first two text cases fail. please help.

@sans_sehgal hey sanskar I can’t see your code please share your code directly copy and paste here

@jaiskid here you go:

#include #include #include using namespace std; bool checkValid(string s) { stack stc; for(int i=0; i<s.length(); i++) { if(s[i]==’(’) stc.push(’(’); else if(s[i]==’)’) { if(!stc.empty()) stc.pop(); else { return false; break; } } } return stc.empty(); } int main() { string s; getline(cin , s); if(checkValid(s)==1) cout<<β€œyes”; else cout<<β€œno”; }

@sans_sehgal hey sanskar this is because you have to include this to also {,[

#include #include #include using namespace std; bool checkValid(string s) { stack stc; for(int i=0; i<s.length(); i++) { if(s[i]==’(’ || s[i]== β€˜{’ || s[i]==’[’) { stc.push(’(’); } else if(s[i]==’)’ || s[i]== β€˜}’ || s[i]==’]’) { if(!stc.empty()) stc.pop(); else { return false; break; } } } return stc.empty(); } int main() { string s; getline(cin , s); if(checkValid(s)==1) cout<<β€œYes”; else cout<<β€œNo”; }

@sans_sehgal hey sanskar please share your code through coding blocks ide

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.