I have tried all the testcases, and my code is working fine.
but it’s still showing me WA, there might be a corner case which i am missing,
I request you to help me correct my code…i am using c++
problem link: https://www.spoj.com/problems/MMASS/
my code: https://ide.geeksforgeeks.org/sXzEEAwzM5
problem code: MMASS
I am really thankful to you..
Input : HH(HH)(HH)2
Correct Output : 8
Your Output : 10
… and a lot more cases like this… The problem in your code is whenever your code sees something like “)NUM” you are multiplying the current sum with NUM instead you should multiply to only that part of sum which results from a pair or parentheses.
##HERE is my answer to same question… I guess you both have same type of mistake of not identifying matching brackets…
Feel free to ask queries further… trying to avoid writing again same type of answer again… so U can have a look at that link and reply if u still have any query…
one more doubt on same question
can anyone explain the solution using stack as there are nested brackets