- 1
Bracket matcher
Input is "(coder)(byte))" output is 0 Input is "(c(oder)) b(yte)" output is 1
5 Antworten
+ 6
share your attempt on this problem so that we could guide you on solving it.
its of no use for me and you to just copy paste and learn nothing on the way.
+ 6
well leme give you a direction.
i assume you are just finding () matches.
just initialize a variable to 0
and iterate through the input string and if you find '(' just increment that variable and if you encounter ')' then decrement it..
finally check if the variable is 0 ..if its not then it isnt balanced .
hope you got it now!?
if you want to match for [] {} too then you could try stack DS. leme know if you need it?
+ 1
Just edit your question and put the "mfd" tag and hope you will get the answer soon.
0
Good
- 1
Ya ya in the backets contain some string