Medium
Quiz
#1410 HTML Entity Parser
APPROACH
Implement an HTML entity parser that replaces the following encoded entities in the input string text with their actual characters:
- Quotation Mark: the entity is " and symbol character is ".
- Single Quote Mark: the entity is ' and symbol character is '.
- Ampersand: the entity is & and symbol character is &.
- Greater Than Sign: the entity is > and symbol character is >.
- Less Than Sign: the entity is < and symbol character is <.
- Slash: the entity is ⁄ and symbol character is /.
Return the decoded string.
Example 1:
Input: text = "& is an HTML entity but &ambassador; is not."
Output: "& is an HTML entity but &ambassador; is not."
Explanation: The parser will replace the & entity by &
Example 2:
Input: text = "and I quote: "...""
Output: "and I quote: \"...\""
1 of 4
1:00
What is the optimal approach for this problem?