Why we have used return s.empty() here

Stack.empty() will return true if stack is empty and false if stack is not empty.
Here
You can use
If(stack.empty()==true)
Return true
Else
Return false

.
.
.WE are using this for test case
(()
This should return false…so we are checking whether stack is empty at end or not.
Hit like if u get it.

Hey Gaurav,
As you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.

Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.

you mean if expresssion is Valid than stack SHOULD ALWAYS be empty at the end…and it CAN BE invalid if stack is not empty.

yes.Stack should be empty at end otherwise it would be an invalid expression.
Stack empty means No of opening brackets = No of ending brackets

1 Like

thank you…