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 &lt; and symbol character is <.

- Slash: the entity is &frasl; and symbol character is /.

Return the decoded string.

Example 1:

Input: text = "&amp; is an HTML entity but &ambassador; is not."
Output: "& is an HTML entity but &ambassador; is not."
Explanation: The parser will replace the &amp; 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?