Simplified XML Validator
Updated
Problem statement
Given an ASCII string text, return whether it is valid under this simplified XML format.
The string consists of ordinary content and tags:
- Ordinary content may contain any ASCII character except
<and>. - An opening tag has the form
<name>. - A closing tag has the form
</name>. - A tag name is a non-empty sequence of visible ASCII characters that contains none of
<,>, or/. - Opening and closing tags must be correctly nested, with none missing or overlapping.
Text is allowed before, after, and between complete tag pairs, so the input does not need one outer root tag. The empty string is valid.
Function
isValidSimplifiedXml(text: String) → booleanExamples
Example 1
text = "text<a>more text</a>"return = trueThe opening and closing a tags match, and ordinary text is allowed outside and inside the pair.
Example 2
text = "<a>text<b>other text</a></b>"return = falseThe closing tags overlap: b must close before a.
Example 3
text = "<invalid<>text</invalid>"return = falseThe opening tag contains another < before it closes.
Constraints
0 <= text.length <= 10^5.textcontains ASCII characters only.
More Airbnb Online Assessment questions
- In-Memory File SystemOA · Seen Nov 2026
- Task Management SystemOA · Seen Nov 2026
- Recipe Management SystemOA · Seen Nov 2026
- Progressive Banking SystemOA · Seen Nov 2026
- Credit Accounts with Scheduled TransfersOA · Seen Oct 2026
- Parcel Attribute Store with TTLOA · Seen Oct 2026
- Parcel Event TrackingOA · Seen Oct 2026
- Median Home Price by CityOA · Seen Sep 2026
- Worker Management (Promotion Track), Part 4: Full-Shift Double PayOA · Seen Sep 2026
- Worker Management (Promotion Track), Part 3: Promotions and SalaryOA · Seen Sep 2026
Similar questions at other companies
- Create New VersionCisco · OACisco interview questions
- Smallest Value for a Linear Expression ModuloIntel · OA
- Most Frequent Call Path From Function Trace LogsRoblox · PHONE SCREEN · ONSITE INTERVIEWRoblox interview questions
- Single-Pass S-Expression ParserBaseten · ONSITE INTERVIEWBaseten interview questions
- Remove Parentheses from a Plus-Minus ExpressionOracle · PHONE SCREENOracle interview questions
- Decode StringCompass International Holdings · PHONE SCREENCompass International Holdings interview questions
- Flatten a Mixed JSON ListNike, Inc. · ONSITE INTERVIEWNike, Inc. interview questions
- Molecular Weight of a Grouped FormulaAgoda · ONSITE INTERVIEWAgoda interview questions
- Calculate a Token-List ExpressionCollege Vine · ONSITE INTERVIEW
- Rich Text Parser Part 3 (Depth Tokens)Figma · PHONE SCREEN · ONSITE INTERVIEWFigma interview questions