mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-07 00:11:41 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给定一个表达式如 <code>expression = \"e + 8 - a + 5\"</code> 和一个求值映射,如 <code>{\"e\": 1}</code>(给定的形式为 <code>evalvars = [\"e\"]</code> 和 <code>evalints = [1]</code>),返回表示简化表达式的标记列表,例如 <code>[\"-1*a\",\"14\"]</code></p>\n\n<ul>\n\t<li>表达式交替使用块和符号,每个块和符号之间有一个空格。</li>\n\t<li>块要么是括号中的表达式,要么是变量,要么是非负整数。</li>\n\t<li>变量是一个由小写字母组成的字符串(不包括数字)。请注意,变量可以是多个字母,并注意变量从不具有像 <code>\"2x\"</code> 或 <code>\"-x\"</code> 这样的前导系数或一元运算符 。</li>\n</ul>\n\n<p>表达式按通常顺序进行求值:先是括号,然后求乘法,再计算加法和减法。</p>\n\n<ul>\n\t<li>例如,<code>expression = \"1 + 2 * 3\"</code> 的答案是 <code>[\"7\"]</code>。</li>\n</ul>\n\n<p>输出格式如下:</p>\n\n<ul>\n\t<li>对于系数非零的每个自变量项,我们按字典排序的顺序将自变量写在一个项中。\n\t<ul>\n\t\t<li>例如,我们永远不会写像 <code>“b*a*c”</code> 这样的项,只写 <code>“a*b*c”</code>。</li>\n\t</ul>\n\t</li>\n\t<li>项的次数等于被乘的自变量的数目,并计算重复项。我们先写出答案的最大次数项,用字典顺序打破关系,此时忽略词的前导系数。\n\t<ul>\n\t\t<li>例如,<code>\"a*a*b*c\"</code> 的次数为 4。</li>\n\t</ul>\n\t</li>\n\t<li>项的前导系数直接放在左边,用星号将它与变量分隔开(如果存在的话)。前导系数 1 仍然要打印出来。</li>\n\t<li>格式良好的一个示例答案是 <code>[\"-2*a*a*a\", \"3*a*a*b\", \"3*b*b\", \"4*a\", \"5*c\", \"-6\"]</code> 。</li>\n\t<li>系数为 <code>0</code> 的项(包括常数项)不包括在内。\n\t<ul>\n\t\t<li>例如,<code>“0”</code> 的表达式输出为 <code>[]</code> 。</li>\n\t</ul>\n\t</li>\n</ul>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<strong>输入:</strong>expression = \"e + 8 - a + 5\", evalvars = [\"e\"], evalints = [1]\n<strong>输出:</strong>[\"-1*a\",\"14\"]\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<strong>输入:</strong>expression = \"e - 8 + temperature - pressure\",\nevalvars = [\"e\", \"temperature\"], evalints = [1, 12]\n<strong>输出:</strong>[\"-1*pressure\",\"5\"]\n</pre>\n\n<p><strong>示例 3:</strong></p>\n\n<pre>\n<strong>输入:</strong>expression = \"(e + 8) * (e - 8)\", evalvars = [], evalints = []\n<strong>输出:</strong>[\"1*e*e\",\"-64\"]\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= expression.length <= 250</code></li>\n\t<li><code>expression</code> 由小写英文字母,数字 <code>'+'</code>, <code>'-'</code>, <code>'*'</code>, <code>'('</code>, <code>')'</code>, <code>' '</code> 组成</li>\n\t<li><code>expression</code> 不包含任何前空格或后空格</li>\n\t<li><code>expression</code> 中的所有符号都用一个空格隔开</li>\n\t<li><code>0 <= evalvars.length <= 100</code></li>\n\t<li><code>1 <= evalvars[i].length <= 20</code></li>\n\t<li><code>evalvars[i]</code> 由小写英文字母组成</li>\n\t<li><code>evalints.length == evalvars.length</code></li>\n\t<li><code>-100 <= evalints[i] <= 100</code></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Hard",
|
||||
"likes": 41,
|
||||
"likes": 44,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[{\"title\": \"Parse Lisp Expression\", \"titleSlug\": \"parse-lisp-expression\", \"difficulty\": \"Hard\", \"translatedTitle\": \"Lisp \\u8bed\\u6cd5\\u89e3\\u6790\"}, {\"title\": \"Basic Calculator III\", \"titleSlug\": \"basic-calculator-iii\", \"difficulty\": \"Hard\", \"translatedTitle\": \"\\u57fa\\u672c\\u8ba1\\u7b97\\u5668 III\"}]",
|
||||
@@ -161,7 +161,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"1.4K\", \"totalSubmission\": \"2.4K\", \"totalAcceptedRaw\": 1360, \"totalSubmissionRaw\": 2384, \"acRate\": \"57.0%\"}",
|
||||
"stats": "{\"totalAccepted\": \"1.4K\", \"totalSubmission\": \"2.5K\", \"totalAcceptedRaw\": 1421, \"totalSubmissionRaw\": 2487, \"acRate\": \"57.1%\"}",
|
||||
"hints": [
|
||||
"One way is with a Polynomial class. For example,\r\n\r\n* `Poly:add(this, that)` returns the result of `this + that`.\r\n* `Poly:sub(this, that)` returns the result of `this - that`.\r\n* `Poly:mul(this, that)` returns the result of `this * that`.\r\n* `Poly:evaluate(this, evalmap)` returns the polynomial after replacing all free variables with constants as specified by `evalmap`.\r\n* `Poly:toList(this)` returns the polynomial in the correct output format.\r\n\r\n* `Solution::combine(left, right, symbol)` returns the result of applying the binary operator represented by `symbol` to `left` and `right`.\r\n* `Solution::make(expr)` makes a new `Poly` represented by either the constant or free variable specified by `expr`.\r\n* `Solution::parse(expr)` parses an expression into a new `Poly`."
|
||||
],
|
||||
|
Reference in New Issue
Block a user