mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-21 21:16:45 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给你一棵以 <code>root</code> 为根的 <strong>二叉树</strong> ,请你返回 <strong>任意</strong> 二叉搜索子树的最大键值和。</p>\n\n<p>二叉搜索树的定义如下:</p>\n\n<ul>\n\t<li>任意节点的左子树中的键值都 <strong>小于</strong> 此节点的键值。</li>\n\t<li>任意节点的右子树中的键值都 <strong>大于</strong> 此节点的键值。</li>\n\t<li>任意节点的左子树和右子树都是二叉搜索树。</li>\n</ul>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<p><img alt=\"\" src=\"https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/03/07/sample_1_1709.png\" style=\"height: 250px; width: 320px;\" /></p>\n\n<pre>\n<strong>输入:</strong>root = [1,4,3,2,4,2,5,null,null,null,null,null,null,4,6]\n<strong>输出:</strong>20\n<strong>解释:</strong>键值为 3 的子树是和最大的二叉搜索树。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<p><img alt=\"\" src=\"https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/03/07/sample_2_1709.png\" style=\"height: 180px; width: 134px;\" /></p>\n\n<pre>\n<strong>输入:</strong>root = [4,3,null,1,2]\n<strong>输出:</strong>2\n<strong>解释:</strong>键值为 2 的单节点子树是和最大的二叉搜索树。\n</pre>\n\n<p><strong>示例 3:</strong></p>\n\n<pre>\n<strong>输入:</strong>root = [-4,-2,-5]\n<strong>输出:</strong>0\n<strong>解释:</strong>所有节点键值都为负数,和最大的二叉搜索树为空。\n</pre>\n\n<p><strong>示例 4:</strong></p>\n\n<pre>\n<strong>输入:</strong>root = [2,1,3]\n<strong>输出:</strong>6\n</pre>\n\n<p><strong>示例 5:</strong></p>\n\n<pre>\n<strong>输入:</strong>root = [5,4,8,3,null,6,3]\n<strong>输出:</strong>7\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li>每棵树有 <code>1</code> 到 <code>40000</code> 个节点。</li>\n\t<li>每个节点的键值在 <code>[-4 * 10^4 , 4 * 10^4]</code> 之间。</li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Hard",
|
||||
"likes": 86,
|
||||
"likes": 90,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -161,7 +161,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"12.5K\", \"totalSubmission\": \"30.3K\", \"totalAcceptedRaw\": 12467, \"totalSubmissionRaw\": 30257, \"acRate\": \"41.2%\"}",
|
||||
"stats": "{\"totalAccepted\": \"13.4K\", \"totalSubmission\": \"32.2K\", \"totalAcceptedRaw\": 13361, \"totalSubmissionRaw\": 32162, \"acRate\": \"41.5%\"}",
|
||||
"hints": [
|
||||
"Create a datastructure with 4 parameters: (sum, isBST, maxLeft, minLeft).",
|
||||
"In each node compute theses parameters, following the conditions of a Binary Search Tree."
|
||||
|
Reference in New Issue
Block a user