← All questions
HardCoding
Tag Validator
Asked at
Microsoft
1Give yourself 5 minutes
2Answer out loud, not in your head
3Then compare with the answer below
0
Stuck? Show a way to structure it+
- 01Require the document to begin with an opening tag.
- 02Scan tags and CDATA blocks with index bounds checks.
- 03Push valid opening names and match every closing name to stack top.
- 04Reject trailing text after the root closes and accept only an empty final stack.
Reference answer
Then expect these follow-ups
Why is a stack necessary rather than a set?
Tests: nesting order
How would you report the first syntax error?
Tests: parser diagnostics
Free to read · better with Enzo
Practice this out loud with Enzo
Enzo runs it as a mock interview, pushes back with follow-ups, and grades you on the rubric.
Next question