ABCC - Editorial

Your attempt is interesting, but assumes that a β€˜b’ is exclusive for a single swap. The same β€˜b’ can be used for many swaps, you cannot pop it.

Try only detecting it, but not popping it.

Your code is very smooth and very well commented tho, so beautiful to read :hugs:

Thanks, @ulisesaugusto1 . I made two changes and was able to solve this:

  1. Not pop the content if there’s a match (as you suggested)
  2. Replace stack with queue to match the earliest opening bracket rather than nearest (as per one of your above discussion)
    Submission: CodeChef: Practical coding for everyone
1 Like