Ad
  • Default User Avatar

    To add on, I think it's also because the pair of brackets will only be replaced with "" if the open and close brackets are in the correct order, of the same type as well as next to each other, on each iteration. By the last iteration, it should give you a "" if the bracket orderings are valid.