1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-05 07:21:40 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-05-02 23:44:12 +08:00
parent 7ea03594b3
commit 2a71c78585
4790 changed files with 11696 additions and 10944 deletions

View File

@@ -12,7 +12,7 @@
"translatedContent": "<p>「HTML&nbsp;实体解析器」 是一种特殊的解析器,它将 HTML 代码作为输入,并用字符本身替换掉所有这些特殊的字符实体。</p>\n\n<p>HTML 里这些特殊字符和它们对应的字符实体包括:</p>\n\n<ul>\n\t<li><strong>双引号:</strong>字符实体为&nbsp;<code>&amp;quot;</code>&nbsp;,对应的字符是&nbsp;<code>&quot;</code>&nbsp;。</li>\n\t<li><strong>单引号:</strong>字符实体为&nbsp;<code>&amp;apos;</code>&nbsp;,对应的字符是&nbsp;<code>&#39;</code>&nbsp;。</li>\n\t<li><strong>与符号:</strong>字符实体为&nbsp;<code>&amp;amp;</code>&nbsp;,对应对的字符是&nbsp;<code>&amp;</code>&nbsp;。</li>\n\t<li><strong>大于号:</strong>字符实体为&nbsp;<code>&amp;gt;</code>&nbsp;,对应的字符是&nbsp;<code>&gt;</code>&nbsp;。</li>\n\t<li><strong>小于号:</strong>字符实体为&nbsp;<code>&amp;lt;</code>&nbsp;,对应的字符是&nbsp;<code>&lt;</code>&nbsp;。</li>\n\t<li><strong>斜线号:</strong>字符实体为&nbsp;<code>&amp;frasl;</code>&nbsp;,对应的字符是&nbsp;<code>/</code>&nbsp;。</li>\n</ul>\n\n<p>给你输入字符串&nbsp;<code>text</code>&nbsp;,请你实现一个 HTML&nbsp;实体解析器,返回解析器解析后的结果。</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<pre>\n<strong>输入:</strong>text = &quot;&amp;amp; is an HTML entity but &amp;ambassador; is not.&quot;\n<strong>输出:</strong>&quot;&amp; is an HTML entity but &amp;ambassador; is not.&quot;\n<strong>解释:</strong>解析器把字符实体 &amp;amp; 用 &amp; 替换\n</pre>\n\n<p><strong>示例&nbsp;2</strong></p>\n\n<pre>\n<strong>输入:</strong>text = &quot;and I quote: &amp;quot;...&amp;quot;&quot;\n<strong>输出:</strong>&quot;and I quote: \\&quot;...\\&quot;&quot;\n</pre>\n\n<p><strong>示例 3</strong></p>\n\n<pre>\n<strong>输入:</strong>text = &quot;Stay home! Practice on Leetcode :)&quot;\n<strong>输出:</strong>&quot;Stay home! Practice on Leetcode :)&quot;\n</pre>\n\n<p><strong>示例 4</strong></p>\n\n<pre>\n<strong>输入:</strong>text = &quot;x &amp;gt; y &amp;amp;&amp;amp; x &amp;lt; y is always false&quot;\n<strong>输出:</strong>&quot;x &gt; y &amp;&amp; x &lt; y is always false&quot;\n</pre>\n\n<p><strong>示例 5</strong></p>\n\n<pre>\n<strong>输入:</strong>text = &quot;leetcode.com&amp;frasl;problemset&amp;frasl;all&quot;\n<strong>输出:</strong>&quot;leetcode.com/problemset/all&quot;\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= text.length &lt;= 10^5</code></li>\n\t<li>字符串可能包含 256 个ASCII 字符中的任意字符。</li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 17,
"likes": 18,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -143,7 +143,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"8K\", \"totalSubmission\": \"16.8K\", \"totalAcceptedRaw\": 7992, \"totalSubmissionRaw\": 16809, \"acRate\": \"47.5%\"}",
"stats": "{\"totalAccepted\": \"8.1K\", \"totalSubmission\": \"17K\", \"totalAcceptedRaw\": 8099, \"totalSubmissionRaw\": 17018, \"acRate\": \"47.6%\"}",
"hints": [
"Search the string for all the occurrences of the character '&'.",
"For every '&' check if it matches an HTML entity by checking the ';' character and if entity found replace it in the answer."