Pls check the code its giving wrng o/p
Why are you calculating c in this program? What’s need of doing it?
in case if it is less than 1…tht would mean that there is no data in btwn ie something like this
() which means duplition
its done now
thanku
Actually i hv initialised c outside for loop thatswhy it was not giving correct o/p
Instead do it like this,
for(int i=0; i<n; i++){ char ch = s[i]; if(ch == '(') t.push(ch); else if(ch ==‘)’){ char temp = t.top(); if(s[i] == ')' && temp == '('){ t.pop(); }else t.push(ch); } }
if(t.empty()==true){
return true;
}
else{
return false;
}
If your solution got accepted, please mark it as resolved.