Mission 5: "Validating the Energy Fields" 🗼

The validation code needs to handle opening brackets. When one is found, it must be stored to wait for its matching closer.

00:00

Step 1 / 2

1. The Story: The Mission Briefing

"To access the next sector, you must pass through a series of nested energy fields. The activation sequence must be perfectly balanced. Your task is to write a validator for the activation code."

2. The Problem

How do you check if a sequence of parentheses, brackets, and braces is correctly matched and balanced (e.g., {[()]} )?

3. The Task

You will implement a Stack. As your code scans the sequence, you push opening brackets onto the stack. When you encounter a closing bracket, you pop the stack and check if it's the matching type. If the stack is empty at the end, the sequence is valid.

4. Concepts Applied

Practical use of a Stack for balancing and syntax validation.

Editor