Balanced parenthesis- seg error

include<bits/stdc++.h>
using namespace std;

bool check(char *ch)
{
stacks;

for(int i=0;ch[i]!='\0';i++)
{
	if(ch[i]=='(')
	s.push(ch[i]);
	else if(ch[i]==')')
	{
		if(s.top()==')' || s.empty())
		return false;			
	}
	s.pop();
}
return true;

}

int main() {
char ch[256];
cin.getline(ch,256);

if(check(ch))
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;

// for(int i=0;i<n;i++)
// s.push(i);
return 0;

}

hello @vashishthkuntal.gajjar2019

image

u have handled only one type of brackets , there can be other type of brackets as well .

also u have to return true only when stack is empty after processing otherwise return false

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.