I have a doubt in a question,,,,,, i want to know the ans of my code for specific input (question linkis attached in answer)


this is the approach of solution please explain this code with the given input

( ) ( ( ) this input is also mentioned in comments of the code , please explain a show me a dry run for this specific input, tell me the answer should be 2 or 4 ???

hello @shashank_sabharwal

answer should be 2 because here we have only () substring which is valid.

the approach is exaclty same as balanced paranthesis problem (pls watch stack playlist of ur course).

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.