You are not logged in. Please login at to post your questions!


Is Question Understanding Is Wrong Or Solution Of ZCO Matched Brackets 2?

I am solving ZCO Matched Brackets 2.

Question Link : ZCO12003

My Explanation To My Solution:

First i am checking for Maximum Alternative Depth in the first for loop.
I am checking it by taking the observation of brackets.
If i encounter bracket ( after [ or bracket [ after ( then i increment my conter by 1 and storing the maximum ans to a variable.
In second loop i am checking for the maximum number of brackets between ( ) (Inclusive) and maximum number of brackets between [ ] (Inclusive) and printing the answer.

My Solution: My Code

asked 31 Jan, 23:21

crackercode's gravatar image

accept rate: 0%

edited 03 Feb, 12:34

I looked at your code. I don't think there is any issue with queries of type 2 and 3. The issue is with computation of alternating depth. Instead of giving away the error to you and spoiling the fun, let's give you a test case for which your solution fails ;)

View Content

For this, your solution prints an alternating depth of 0. while the answer should be 2.
Happy debugging :)

If you still have any issues, feel free to ask them.


answered 03 Feb, 13:35

akashbhalotia's gravatar image

accept rate: 10%

edited 03 Feb, 13:36

toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 31 Jan, 23:21

question was seen: 128 times

last updated: 03 Feb, 14:24