- 1

Bracket matcher

Input is "(coder)(byte))" output is 0 Input is "(c(oder)) b(yte)" output is 1

17th Jun 2021, 11:22 AM
Dasari Krishna
Dasari Krishna - avatar
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.
17th Jun 2021, 11:28 AM
Prashanth Kumar
Prashanth Kumar - avatar
+ 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?
17th Jun 2021, 11:51 AM
Prashanth Kumar
Prashanth Kumar - avatar
+ 1
Just edit your question and put the "mfd" tag and hope you will get the answer soon.
17th Jun 2021, 11:55 AM
The future is now thanks to science
The future is now thanks to science - avatar
0
Good
12th Apr 2023, 1:56 AM
Moussa Mehiri
- 1
Ya ya in the backets contain some string
17th Jun 2021, 12:00 PM
Dasari Krishna
Dasari Krishna - avatar