1410. HTML Entity Parser Medium

@problem@discussion
#Hash Table#String



1/**
2 * [1410] HTML Entity Parser
3 *
4 * HTML entity parser is the parser that takes HTML code as input and replace all the entities of the special characters by the characters itself.
5 * The special characters and their entities for HTML are:
6 * 
7 * 	Quotation Mark: the entity is " and symbol character is ".
8 * 	Single Quote Mark: the entity is ' and symbol character is '.
9 * 	Ampersand: the entity is & and symbol character is &.
10 * 	Greater Than Sign: the entity is > and symbol character is >.
11 * 	Less Than Sign: the entity is &amp;lt; and symbol character is <.
12 * 	Slash: the entity is &amp;frasl; and symbol character is /.
13 * 
14 * Given the input text string to the HTML parser, you have to implement the entity parser.
15 * Return the text after replacing the entities by the special characters.
16 *  
17 * Example 1:
18 * 
19 * Input: text = "&amp;amp; is an HTML entity but &amp;ambassador; is not."
20 * Output: "&amp; is an HTML entity but &amp;ambassador; is not."
21 * Explanation: The parser will replace the &amp;amp; entity by &amp;
22 * 
23 * Example 2:
24 * 
25 * Input: text = "and I quote: &amp;quot;...&amp;quot;"
26 * Output: "and I quote: \"...\""
27 * 
28 *  
29 * Constraints:
30 * 
31 * 	1 <= text.length <= 10^5
32 * 	The string may contain any possible characters out of all the 256 ASCII characters.
33 * 
34 */
35pub struct Solution {}
36
37// problem: https://leetcode.com/problems/html-entity-parser/
38// discuss: https://leetcode.com/problems/html-entity-parser/discuss/?currentPage=1&orderBy=most_votes&query=
39
40// submission codes start here
41
42impl Solution {
43    pub fn entity_parser(text: String) -> String {
44        String::new()
45    }
46}
47
48// submission codes end
49
50#[cfg(test)]
51mod tests {
52    use super::*;
53
54    #[test]
55    fn test_1410() {
56    }
57}
58


Back
© 2025 bowen.ge All Rights Reserved.