Balanced Brackets

Talk it through out loud with your AI coach.

The problem

  • easy

Given a string made of round, square and curly brackets, decide whether every opening bracket is closed by the same kind of bracket, in the right order. For example, round-square-close-square-close-round is fine, but round-square-close-round-close-square is not. Explain your approach.

What a strong answer covers

  • Why the most recent unmatched opener is the one that matters.
  • What to check when a closing bracket appears.
  • The condition for success at the end.
  • The cost and the edge cases that catch people out.

Common mistake: Only counting openers and closers, which can't tell whether the kinds and the order match.

Knowing this is half of it. Saying it clearly out loud is the part the coach helps you practise.

Practise it out loud