{"id":66790,"date":"2026-01-27T16:04:53","date_gmt":"2026-01-27T08:04:53","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/66790.html"},"modified":"2026-01-27T16:04:53","modified_gmt":"2026-01-27T08:04:53","slug":"day14-%e4%bb%a3%e7%a0%81%e9%9a%8f%e6%83%b3%e5%bd%95%e7%ae%97%e6%b3%95%e8%ae%ad%e7%bb%83%e8%90%a5-%e4%ba%8c%e5%8f%89%e6%a0%91%e4%b8%93%e9%a2%982","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/66790.html","title":{"rendered":"day14 \u4ee3\u7801\u968f\u60f3\u5f55\u7b97\u6cd5\u8bad\u7ec3\u8425 \u4e8c\u53c9\u6811\u4e13\u98982"},"content":{"rendered":"<h2>1 \u4eca\u65e5\u6253\u5361\u9898<\/h2>\n<p>\u7ffb\u8f6c\u4e8c\u53c9\u6811\u00a0226. \u7ffb\u8f6c\u4e8c\u53c9\u6811 &#8211; \u529b\u6263&#xff08;LeetCode&#xff09;<\/p>\n<p>\u5bf9\u79f0\u4e8c\u53c9\u6811\u00a0101. \u5bf9\u79f0\u4e8c\u53c9\u6811 &#8211; \u529b\u6263&#xff08;LeetCode&#xff09;<\/p>\n<p>\u4e8c\u53c9\u6811\u7684\u6700\u5927\u6df1\u5ea6\u00a0104. \u4e8c\u53c9\u6811\u7684\u6700\u5927\u6df1\u5ea6 &#8211; \u529b\u6263&#xff08;LeetCode&#xff09;<\/p>\n<p>\u4e8c\u53c9\u6811\u7684\u6700\u5c0f\u6df1\u5ea6\u00a0111. \u4e8c\u53c9\u6811\u7684\u6700\u5c0f\u6df1\u5ea6 &#8211; \u529b\u6263&#xff08;LeetCode&#xff09;<\/p>\n<h2 style=\"background-color:transparent\">2 \u7ffb\u8f6c\u4e8c\u53c9\u6811<\/h2>\n<h3>2.1 \u601d\u8def<\/h3>\n<p>\u7ffb\u8f6c\u4e8c\u53c9\u6811\u7684\u672c\u8d28\u662f&#xff1a;\u628a\u4e8c\u53c9\u6811\u4e2d\u6bcf\u4e2a\u8282\u70b9\u7684\u5de6\u5b50\u8282\u70b9\u548c\u53f3\u5b50\u8282\u70b9\u4ea4\u6362\u4f4d\u7f6e&#xff0c;\u5e76\u4e14\u8fd9\u4e2a\u64cd\u4f5c\u9700\u8981\u9012\u5f52\u5730\u5e94\u7528\u5230\u6240\u6709\u8282\u70b9\u4e0a&#xff08;\u5305\u62ec\u5b50\u6811\u7684\u8282\u70b9&#xff09;\u3002\u9012\u5f52\u7684\u6838\u5fc3\u903b\u8f91\u53ef\u4ee5\u62c6\u89e3\u4e3a 3 \u6b65&#xff1a; \u7ec8\u6b62\u6761\u4ef6&#xff1a;\u5982\u679c\u5f53\u524d\u8282\u70b9\u4e3a null&#xff08;\u7a7a\u8282\u70b9&#xff09;&#xff0c;\u76f4\u63a5\u8fd4\u56de&#xff0c;\u65e0\u9700\u53cd\u8f6c&#xff08;\u9012\u5f52\u7684\u51fa\u53e3&#xff0c;\u907f\u514d\u65e0\u9650\u9012\u5f52&#xff09;\u3002 \u5904\u7406\u5f53\u524d\u8282\u70b9&#xff1a;\u4ea4\u6362\u5f53\u524d\u8282\u70b9\u7684\u5de6\u3001\u53f3\u5b50\u8282\u70b9\u3002 \u9012\u5f52\u5904\u7406\u5b50\u8282\u70b9&#xff1a;\u5206\u522b\u5bf9\u5f53\u524d\u8282\u70b9\u7684\u5de6\u5b50\u6811\u3001\u53f3\u5b50\u6811\u6267\u884c\u53cd\u8f6c\u64cd\u4f5c&#xff08;\u56e0\u4e3a\u5b50\u6811\u672c\u8eab\u4e5f\u662f\u4e00\u68f5\u4e8c\u53c9\u6811&#xff0c;\u9700\u8981\u540c\u6837\u7684\u903b\u8f91\u53cd\u8f6c&#xff09;\u3002<\/p>\n<p>\u53ef\u4ee5\u7528\u524d\u5e8f\u904d\u5386\u6216\u8005\u540e\u5e8f\u904d\u5386\u3002\u4f46\u662f\u4e2d\u5e8f\u904d\u5386\u4e0d\u884c&#xff0c;\u56e0\u4e3a\u6709\u7684\u4f1a\u7ffb\u8f6c2\u6b21&#xff0c;\u6709\u7684\u904d\u5386\u4e0d\u5230\u3002<\/p>\n<h3>2.2 \u5b9e\u73b0\u4ee3\u7801<\/h3>\n<p>class Solution {<br \/>\n    \/\/ \u4e3b\u65b9\u6cd5&#xff1a;\u53cd\u8f6c\u4e8c\u53c9\u6811&#xff0c;\u8fd4\u56de\u53cd\u8f6c\u540e\u7684\u6839\u8282\u70b9<br \/>\n    public TreeNode invertTree(TreeNode root) {<br \/>\n        \/\/ \u9012\u5f52\u7ec8\u6b62\u6761\u4ef6&#xff1a;\u5f53\u524d\u8282\u70b9\u4e3a\u7a7a&#xff0c;\u76f4\u63a5\u8fd4\u56de&#xff08;\u6ca1\u6709\u53ef\u53cd\u8f6c\u7684\u8282\u70b9&#xff09;<br \/>\n        if (root &#061;&#061; null) {<br \/>\n            return root;<br \/>\n        }<\/p>\n<p>        \/\/ \u7b2c\u4e00\u6b65&#xff1a;\u5904\u7406\u5f53\u524d\u8282\u70b9\u2014\u2014\u4ea4\u6362\u5f53\u524d\u8282\u70b9\u7684\u5de6\u3001\u53f3\u5b50\u8282\u70b9<br \/>\n        swap(root);<\/p>\n<p>        \/\/ \u7b2c\u4e8c\u6b65&#xff1a;\u9012\u5f52\u53cd\u8f6c\u5de6\u5b50\u6811&#xff08;\u5de6\u5b50\u6811\u4e5f\u662f\u4e00\u68f5\u4e8c\u53c9\u6811&#xff0c;\u9700\u8981\u540c\u6837\u7684\u903b\u8f91&#xff09;<br \/>\n        invertTree(root.left);<\/p>\n<p>        \/\/ \u7b2c\u4e09\u6b65&#xff1a;\u9012\u5f52\u53cd\u8f6c\u53f3\u5b50\u6811&#xff08;\u53f3\u5b50\u6811\u4e5f\u662f\u4e00\u68f5\u4e8c\u53c9\u6811&#xff0c;\u9700\u8981\u540c\u6837\u7684\u903b\u8f91&#xff09;<br \/>\n        invertTree(root.right);<\/p>\n<p>        \/\/ \u8fd4\u56de\u53cd\u8f6c\u540e\u7684\u6839\u8282\u70b9<br \/>\n        return root;<br \/>\n    }<\/p>\n<p>    \/\/ \u8f85\u52a9\u65b9\u6cd5&#xff1a;\u4ea4\u6362\u4e00\u4e2a\u8282\u70b9\u7684\u5de6\u3001\u53f3\u5b50\u8282\u70b9<br \/>\n    private void swap(TreeNode node) {<br \/>\n        \/\/ \u4e34\u65f6\u53d8\u91cf\u4fdd\u5b58\u5de6\u5b50\u8282\u70b9<br \/>\n        TreeNode temp &#061; node.left;<br \/>\n        \/\/ \u628a\u53f3\u5b50\u8282\u70b9\u8d4b\u503c\u7ed9\u5de6\u5b50\u8282\u70b9<br \/>\n        node.left &#061; node.right;<br \/>\n        \/\/ \u628a\u4e34\u65f6\u4fdd\u5b58\u7684\u5de6\u5b50\u8282\u70b9\u8d4b\u503c\u7ed9\u53f3\u5b50\u8282\u70b9<br \/>\n        node.right &#061; temp;<br \/>\n    }<br \/>\n} <\/p>\n<h2 style=\"background-color:transparent\">3 \u5bf9\u79f0\u4e8c\u53c9\u6811<\/h2>\n<h3>3.1 \u601d\u8def<\/h3>\n<p>\u5224\u65ad\u4e00\u68f5\u4e8c\u53c9\u6811\u662f\u5426\u5bf9\u79f0&#xff0c;\u672c\u8d28\u662f\u5224\u65ad\u4e8c\u53c9\u6811\u7684\u5de6\u5b50\u6811\u548c\u53f3\u5b50\u6811\u662f\u5426\u4e92\u4e3a\u955c\u50cf&#xff0c;\u955c\u50cf\u7684\u6838\u5fc3\u6761\u4ef6\u662f&#xff1a; \u4e24\u4e2a\u5bf9\u5e94\u8282\u70b9\u7684\u503c\u76f8\u7b49&#xff1b; \u8282\u70b9 A \u7684\u5de6\u5b50\u8282\u70b9 \u8981\u548c \u8282\u70b9 B \u7684\u53f3\u5b50\u8282\u70b9 \u5bf9\u79f0&#xff1b; \u8282\u70b9 A \u7684\u53f3\u5b50\u8282\u70b9 \u8981\u548c \u8282\u70b9 B \u7684\u5de6\u5b50\u8282\u70b9 \u5bf9\u79f0&#xff1b; \u9012\u5f52\u7ec8\u6b62\u6761\u4ef6&#xff1a;\u8981\u4e48\u4e24\u4e2a\u8282\u70b9\u90fd\u4e3a\u7a7a&#xff08;\u5bf9\u79f0&#xff09;&#xff0c;\u8981\u4e48\u4e00\u4e2a\u4e3a\u7a7a\u4e00\u4e2a\u4e0d\u4e3a\u7a7a&#xff08;\u4e0d\u5bf9\u79f0&#xff09;&#xff0c;\u8981\u4e48\u503c\u4e0d\u76f8\u7b49&#xff08;\u4e0d\u5bf9\u79f0&#xff09;\u3002<\/p>\n<p>\u9012\u5f52\u7684\u903b\u8f91\u662f&#xff1a;\u5148\u5224\u65ad\u5f53\u524d\u5c42\u7684\u4e24\u4e2a\u8282\u70b9\u662f\u5426\u5bf9\u79f0&#xff0c;\u518d\u9012\u5f52\u5224\u65ad\u5185\u5c42\u3001\u5916\u5c42\u5b50\u8282\u70b9\u662f\u5426\u90fd\u5bf9\u79f0&#xff0c;\u53ea\u6709\u6240\u6709\u5c42\u7ea7\u90fd\u6ee1\u8db3&#xff0c;\u624d\u662f\u5bf9\u79f0\u4e8c\u53c9\u6811\u3002<\/p>\n<\/p>\n<h3>3.2 \u5b9e\u73b0\u4ee3\u7801<\/h3>\n<p>class Solution {<br \/>\n    \/\/ \u4e3b\u65b9\u6cd5&#xff1a;\u5224\u65ad\u4e8c\u53c9\u6811\u662f\u5426\u5bf9\u79f0<br \/>\n    public boolean isSymmetric(TreeNode root) {<br \/>\n        \/\/ \u7279\u6b8a\u60c5\u51b5&#xff1a;\u6839\u8282\u70b9\u4e3a\u7a7a&#xff0c;\u76f4\u63a5\u8ba4\u4e3a\u662f\u5bf9\u79f0\u7684<br \/>\n        if (root &#061;&#061; null) {<br \/>\n            return true;<br \/>\n        }<br \/>\n        \/\/ \u6838\u5fc3\u903b\u8f91&#xff1a;\u6bd4\u8f83\u6839\u8282\u70b9\u7684\u5de6\u5b50\u6811\u548c\u53f3\u5b50\u6811\u662f\u5426\u4e92\u4e3a\u955c\u50cf<br \/>\n        return compare(root.left, root.right);<br \/>\n    }<\/p>\n<p>    \/\/ \u8f85\u52a9\u9012\u5f52\u65b9\u6cd5&#xff1a;\u6bd4\u8f83\u4e24\u4e2a\u8282\u70b9&#xff08;\u5de6\u5b50\u6811\u8282\u70b9\u548c\u53f3\u5b50\u6811\u8282\u70b9&#xff09;\u662f\u5426\u5bf9\u79f0<br \/>\n    private boolean compare(TreeNode left, TreeNode right) {<br \/>\n        \/\/ \u60c5\u51b51&#xff1a;\u5de6\u8282\u70b9\u4e3a\u7a7a&#xff0c;\u53f3\u8282\u70b9\u4e0d\u4e3a\u7a7a \u2192 \u4e0d\u5bf9\u79f0<br \/>\n        if (left &#061;&#061; null &amp;&amp; right !&#061; null) {<br \/>\n            return false;<br \/>\n        }<br \/>\n        \/\/ \u60c5\u51b52&#xff1a;\u5de6\u8282\u70b9\u4e0d\u4e3a\u7a7a&#xff0c;\u53f3\u8282\u70b9\u4e3a\u7a7a \u2192 \u4e0d\u5bf9\u79f0<br \/>\n        else if (left !&#061; null &amp;&amp; right &#061;&#061; null) {<br \/>\n            return false;<br \/>\n        }<br \/>\n        \/\/ \u60c5\u51b53&#xff1a;\u5de6\u53f3\u8282\u70b9\u90fd\u4e3a\u7a7a \u2192 \u5bf9\u79f0&#xff08;\u9012\u5f52\u7ec8\u6b62\u7684\u6709\u6548\u6761\u4ef6&#xff09;<br \/>\n        else if (left &#061;&#061; null &amp;&amp; right &#061;&#061; null) {<br \/>\n            return true;<br \/>\n        }<br \/>\n        \/\/ \u60c5\u51b54&#xff1a;\u5de6\u53f3\u8282\u70b9\u90fd\u4e0d\u4e3a\u7a7a&#xff0c;\u4f46\u503c\u4e0d\u76f8\u7b49 \u2192 \u4e0d\u5bf9\u79f0<br \/>\n        else if (left.val !&#061; right.val) {<br \/>\n            return false;<br \/>\n        }<\/p>\n<p>        \/\/ \u8d70\u5230\u8fd9\u91cc&#xff0c;\u8bf4\u660e\u5f53\u524d\u5de6\u53f3\u8282\u70b9\u503c\u76f8\u7b49&#xff0c;\u9700\u8981\u9012\u5f52\u5224\u65ad\u300c\u5916\u5c42\u300d\u548c\u300c\u5185\u5c42\u300d\u662f\u5426\u90fd\u5bf9\u79f0<br \/>\n        \/\/ \u5916\u5c42&#xff1a;\u5de6\u8282\u70b9\u7684\u5de6\u5b50\u8282\u70b9 \u2194 \u53f3\u8282\u70b9\u7684\u53f3\u5b50\u8282\u70b9&#xff08;\u955c\u50cf\u7684\u5916\u4fa7&#xff09;<br \/>\n        boolean outside &#061; compare(left.left, right.right);<br \/>\n        \/\/ \u5185\u5c42&#xff1a;\u5de6\u8282\u70b9\u7684\u53f3\u5b50\u8282\u70b9 \u2194 \u53f3\u8282\u70b9\u7684\u5de6\u5b50\u8282\u70b9&#xff08;\u955c\u50cf\u7684\u5185\u4fa7&#xff09;<br \/>\n        boolean inside &#061; compare(left.right, right.left);<\/p>\n<p>        \/\/ \u53ea\u6709\u5916\u5c42\u548c\u5185\u5c42\u90fd\u5bf9\u79f0&#xff0c;\u5f53\u524d\u4e24\u4e2a\u8282\u70b9\u624d\u662f\u5bf9\u79f0\u7684<br \/>\n        return outside &amp;&amp; inside;<br \/>\n    }<br \/>\n} <\/p>\n<h2 style=\"background-color:transparent\">4 \u4e8c\u53c9\u6811\u7684\u6700\u5927\u6df1\u5ea6<\/h2>\n<h3>4.1 \u601d\u8def<\/h3>\n<p>\u7ec8\u6b62\u6761\u4ef6&#xff1a;\u5982\u679c\u5f53\u524d\u8282\u70b9\u4e3a null&#xff08;\u7a7a\u8282\u70b9&#xff09;&#xff0c;\u6df1\u5ea6\u4e3a 0&#xff08;\u6ca1\u6709\u8282\u70b9\u5c31\u6ca1\u6709\u6df1\u5ea6&#xff09;&#xff1b; \u9012\u5f52\u5206\u89e3&#xff1a;\u5206\u522b\u8ba1\u7b97\u5f53\u524d\u8282\u70b9\u7684\u5de6\u5b50\u6811\u6700\u5927\u6df1\u5ea6\u548c\u53f3\u5b50\u6811\u6700\u5927\u6df1\u5ea6&#xff1b; \u5408\u5e76\u7ed3\u679c&#xff1a;\u5f53\u524d\u8282\u70b9\u7684\u6df1\u5ea6 &#061; \u5de6\u53f3\u5b50\u6811\u6df1\u5ea6\u7684\u6700\u5927\u503c &#043; 1&#xff08;&#043;1 \u662f\u56e0\u4e3a\u8981\u5305\u542b\u5f53\u524d\u8282\u70b9\u672c\u8eab&#xff09;\u3002<\/p>\n<p>\u7528\u540e\u5e8f\u904d\u5386<\/p>\n<h3>4.2 \u5b9e\u73b0\u4ee3\u7801<\/h3>\n<p>class Solution {<br \/>\n    \/\/ \u4e3b\u65b9\u6cd5&#xff1a;\u6c42\u4e8c\u53c9\u6811\u6700\u5927\u6df1\u5ea6<br \/>\n    public int maxDepth(TreeNode root) {<br \/>\n        \/\/ \u7ec8\u6b62\u6761\u4ef6&#xff1a;\u7a7a\u8282\u70b9\u6df1\u5ea6\u4e3a0<br \/>\n        if (root &#061;&#061; null) {<br \/>\n            return 0;<br \/>\n        }<br \/>\n        \/\/ \u9012\u5f52\u8ba1\u7b97\u5de6\u5b50\u6811\u6df1\u5ea6<br \/>\n        int leftDepth &#061; maxDepth(root.left);<br \/>\n        \/\/ \u9012\u5f52\u8ba1\u7b97\u53f3\u5b50\u6811\u6df1\u5ea6<br \/>\n        int rightDepth &#061; maxDepth(root.right);<br \/>\n        \/\/ \u5f53\u524d\u8282\u70b9\u6df1\u5ea6 &#061; \u5de6\u53f3\u5b50\u6811\u6700\u5927\u503c &#043; 1&#xff08;\u5f53\u524d\u8282\u70b9&#xff09;<br \/>\n        return Math.max(leftDepth, rightDepth) &#043; 1;<br \/>\n    }<br \/>\n} <\/p>\n<h2 style=\"background-color:transparent\">5 \u4e8c\u53c9\u6811\u7684\u6700\u5c0f\u6df1\u5ea6<\/h2>\n<h3>5.1 \u601d\u8def<\/h3>\n<p>\u7ec8\u6b62\u6761\u4ef6&#xff1a;\u548c\u6700\u5927\u6df1\u5ea6\u4e00\u81f4 \u2192 \u5982\u679c\u5f53\u524d\u8282\u70b9\u4e3a null&#xff0c;\u8fd4\u56de 0&#xff1b; \u7279\u6b8a\u60c5\u51b5\u5904\u7406&#xff08;\u6700\u5927\u6df1\u5ea6\u6ca1\u6709\u8fd9\u4e00\u6b65&#xff09;&#xff1a; \u5982\u679c\u5f53\u524d\u8282\u70b9\u53ea\u6709\u5de6\u5b50\u6811&#xff08;\u53f3\u5b50\u6811\u4e3a\u7a7a&#xff09;&#xff1a;\u6700\u5c0f\u6df1\u5ea6 &#061; \u5de6\u5b50\u6811\u6df1\u5ea6 &#043; 1&#xff08;\u56e0\u4e3a\u53f3\u5b50\u6811\u4e3a\u7a7a&#xff0c;\u65e0\u6cd5\u6784\u6210\u5230\u53f6\u5b50\u7684\u8def\u5f84&#xff09;&#xff1b; \u5982\u679c\u5f53\u524d\u8282\u70b9\u53ea\u6709\u53f3\u5b50\u6811&#xff08;\u5de6\u5b50\u6811\u4e3a\u7a7a&#xff09;&#xff1a;\u6700\u5c0f\u6df1\u5ea6 &#061; \u53f3\u5b50\u6811\u6df1\u5ea6 &#043; 1&#xff08;\u540c\u7406&#xff09;&#xff1b; \u666e\u901a\u60c5\u51b5&#xff1a;\u5f53\u524d\u8282\u70b9\u65e2\u6709\u5de6\u5b50\u6811\u53c8\u6709\u53f3\u5b50\u6811 \u2192 \u6700\u5c0f\u6df1\u5ea6 &#061; \u5de6\u53f3\u5b50\u6811\u6df1\u5ea6\u7684\u6700\u5c0f\u503c &#043; 1&#xff08;\u548c\u6700\u5927\u6df1\u5ea6\u7684 max \u6539\u4e3a min&#xff09;\u3002<\/p>\n<h3>5.2 \u5b9e\u73b0\u4ee3\u7801<\/h3>\n<p>class Solution {<br \/>\n    public int minDepth(TreeNode root) {<br \/>\n        \/\/ \u7ec8\u6b62\u6761\u4ef6&#xff1a;\u7a7a\u8282\u70b9\u7684\u6df1\u5ea6\u4e3a0<br \/>\n        if (root &#061;&#061; null) {<br \/>\n            return 0;<br \/>\n        }<\/p>\n<p>        \/\/ \u9012\u5f52\u8ba1\u7b97\u5de6\u5b50\u6811\u7684\u6df1\u5ea6<br \/>\n        int leftDepth &#061; minDepth(root.left);<br \/>\n        \/\/ \u9012\u5f52\u8ba1\u7b97\u53f3\u5b50\u6811\u7684\u6df1\u5ea6<br \/>\n        int rightDepth &#061; minDepth(root.right);<\/p>\n<p>        \/\/ \u7279\u6b8a\u60c5\u51b51&#xff1a;\u5f53\u524d\u8282\u70b9\u53ea\u6709\u5de6\u5b50\u6811&#xff08;\u53f3\u5b50\u6811\u4e3a\u7a7a&#xff09;\u2192 \u53ea\u80fd\u8d70\u5de6\u5b50\u6811<br \/>\n        if (root.left !&#061; null &amp;&amp; root.right &#061;&#061; null) {<br \/>\n            return 1 &#043; leftDepth;<br \/>\n        }<br \/>\n        \/\/ \u7279\u6b8a\u60c5\u51b52&#xff1a;\u5f53\u524d\u8282\u70b9\u53ea\u6709\u53f3\u5b50\u6811&#xff08;\u5de6\u5b50\u6811\u4e3a\u7a7a&#xff09;\u2192 \u53ea\u80fd\u8d70\u53f3\u5b50\u6811<br \/>\n        else if (root.left &#061;&#061; null &amp;&amp; root.right !&#061; null) {<br \/>\n            return 1 &#043; rightDepth;<br \/>\n        }<br \/>\n        \/\/ \u666e\u901a\u60c5\u51b5&#xff1a;\u65e2\u6709\u5de6\u5b50\u6811\u53c8\u6709\u53f3\u5b50\u6811 \u2192 \u53d6\u5de6\u53f3\u5b50\u6811\u6df1\u5ea6\u7684\u6700\u5c0f\u503c &#043; \u5f53\u524d\u5c42<br \/>\n        else {<br \/>\n            return 1 &#043; Math.min(leftDepth, rightDepth);<br \/>\n        }<br \/>\n    }<br \/>\n} <\/p>\n<h2>6 \u989d\u5916\u9898\u76ee<\/h2>\n<h3 style=\"background-color:transparent\">6.1 \u76f8\u540c\u7684\u6811&#xff08;\u4e0e\u5bf9\u79f0\u4e8c\u53c9\u6811\u76f8\u4f3c&#xff09;100. \u76f8\u540c\u7684\u6811 &#8211; \u529b\u6263&#xff08;LeetCode&#xff09;<\/h3>\n<h4>6.1.1 \u601d\u8def<\/h4>\n<p>\u7ec8\u6b62\u6761\u4ef6&#xff1a; \u4e24\u68f5\u6811\u7684\u5f53\u524d\u8282\u70b9\u90fd\u4e3a\u7a7a \u2192 \u76f8\u540c&#xff0c;\u8fd4\u56de true&#xff1b; \u4e00\u4e2a\u4e3a\u7a7a\u3001\u4e00\u4e2a\u4e0d\u4e3a\u7a7a \u2192 \u7ed3\u6784\u4e0d\u540c&#xff0c;\u8fd4\u56de false&#xff1b; \u90fd\u4e0d\u4e3a\u7a7a\u4f46\u503c\u4e0d\u76f8\u7b49 \u2192 \u503c\u4e0d\u540c&#xff0c;\u8fd4\u56de false\u3002 \u9012\u5f52\u903b\u8f91&#xff1a; \u5f53\u524d\u8282\u70b9\u6ee1\u8db3\u6761\u4ef6\u540e&#xff0c;\u9012\u5f52\u5224\u65adp \u7684\u5de6\u5b50\u8282\u70b9 \u548c q \u7684\u5de6\u5b50\u8282\u70b9\u662f\u5426\u76f8\u540c&#xff1b; \u9012\u5f52\u5224\u65adp \u7684\u53f3\u5b50\u8282\u70b9 \u548c q \u7684\u53f3\u5b50\u8282\u70b9\u662f\u5426\u76f8\u540c&#xff1b; \u53ea\u6709\u5de6\u53f3\u5b50\u6811\u90fd\u76f8\u540c&#xff0c;\u6574\u68f5\u6811\u624d\u76f8\u540c&#xff08;\u8fd4\u56de left &amp;&amp; right&#xff09;\u3002<\/p>\n<h4>6.1.2 \u5b9e\u73b0\u4ee3\u7801<\/h4>\n<p>class Solution {<br \/>\n    \/\/ \u4e3b\u65b9\u6cd5&#xff1a;\u5224\u65ad\u4e24\u68f5\u6811p\u548cq\u662f\u5426\u5b8c\u5168\u76f8\u540c<br \/>\n    public boolean isSameTree(TreeNode p, TreeNode q) {<br \/>\n        \/\/ \u60c5\u51b51&#xff1a;p\u548cq\u7684\u5f53\u524d\u8282\u70b9\u90fd\u4e3a\u7a7a \u2192 \u7ed3\u6784\u5339\u914d&#xff0c;\u8fd4\u56detrue&#xff08;\u9012\u5f52\u7ec8\u6b62\u6761\u4ef6&#xff09;<br \/>\n        if (p &#061;&#061; null &amp;&amp; q &#061;&#061; null) {<br \/>\n            return true;<br \/>\n        }<br \/>\n        \/\/ \u60c5\u51b52&#xff1a;p\u4e3a\u7a7a\u4f46q\u4e0d\u4e3a\u7a7a \u2192 \u7ed3\u6784\u4e0d\u5339\u914d&#xff0c;\u8fd4\u56defalse&#xff08;\u9012\u5f52\u7ec8\u6b62\u6761\u4ef6&#xff09;<br \/>\n        else if (p &#061;&#061; null &amp;&amp; q !&#061; null) {<br \/>\n            return false;<br \/>\n        }<br \/>\n        \/\/ \u60c5\u51b53&#xff1a;p\u4e0d\u4e3a\u7a7a\u4f46q\u4e3a\u7a7a \u2192 \u7ed3\u6784\u4e0d\u5339\u914d&#xff0c;\u8fd4\u56defalse&#xff08;\u9012\u5f52\u7ec8\u6b62\u6761\u4ef6&#xff09;<br \/>\n        else if (p !&#061; null &amp;&amp; q &#061;&#061; null) {<br \/>\n            return false;<br \/>\n        }<br \/>\n        \/\/ \u60c5\u51b54&#xff1a;p\u548cq\u90fd\u4e0d\u4e3a\u7a7a&#xff0c;\u4f46\u503c\u4e0d\u76f8\u7b49 \u2192 \u503c\u4e0d\u5339\u914d&#xff0c;\u8fd4\u56defalse&#xff08;\u9012\u5f52\u7ec8\u6b62\u6761\u4ef6&#xff09;<br \/>\n        else if (p.val !&#061; q.val) {<br \/>\n            return false;<br \/>\n        }<\/p>\n<p>        \/\/ \u8d70\u5230\u8fd9\u91cc&#xff1a;\u5f53\u524d\u8282\u70b9\u503c\u76f8\u7b49\u3001\u7ed3\u6784\u4e5f\u5339\u914d&#xff0c;\u9700\u8981\u9012\u5f52\u5224\u65ad\u5b50\u8282\u70b9<br \/>\n        \/\/ \u9012\u5f52\u5224\u65ad\u5de6\u5b50\u6811&#xff1a;p\u7684\u5de6\u5b50\u8282\u70b9 \u2194 q\u7684\u5de6\u5b50\u8282\u70b9&#xff08;\u548c\u5bf9\u79f0\u6811\u7684\u6838\u5fc3\u533a\u522b&#xff01;&#xff09;<br \/>\n        boolean left &#061; isSameTree(p.left, q.left);<br \/>\n        \/\/ \u9012\u5f52\u5224\u65ad\u53f3\u5b50\u6811&#xff1a;p\u7684\u53f3\u5b50\u8282\u70b9 \u2194 q\u7684\u53f3\u5b50\u8282\u70b9&#xff08;\u548c\u5bf9\u79f0\u6811\u7684\u6838\u5fc3\u533a\u522b&#xff01;&#xff09;<br \/>\n        boolean right &#061; isSameTree(p.right, q.right);<\/p>\n<p>        \/\/ \u53ea\u6709\u5de6\u53f3\u5b50\u6811\u90fd\u76f8\u540c&#xff0c;\u5f53\u524d\u4e24\u68f5\u6811\u624d\u76f8\u540c<br \/>\n        return left &amp;&amp; right;<br \/>\n    }<br \/>\n} <\/p>\n<h3 style=\"background-color:transparent\">6.2 \u53e6\u4e00\u9897\u6811\u7684\u5b50\u6811572. \u53e6\u4e00\u68f5\u6811\u7684\u5b50\u6811 &#8211; \u529b\u6263&#xff08;LeetCode&#xff09;<\/h3>\n<h4>6.2.1 \u601d\u8def<\/h4>\n<p>\u5728\u76f8\u540c\u7684\u6811\u57fa\u7840\u4e0a\u6539\u9020\u800c\u6765\u3002<\/p>\n<p>\u5224\u65ad subRoot \u662f root \u7684\u5b50\u6811&#xff0c;\u672c\u8d28\u662f&#xff1a;\u628a root \u4e2d\u7684\u6bcf\u4e00\u4e2a\u8282\u70b9\u90fd\u5f53\u4f5c \u201c\u5019\u9009\u6839\u8282\u70b9\u201d&#xff0c;\u68c0\u67e5\u4ee5\u8be5\u8282\u70b9\u4e3a\u6839\u7684\u5b50\u6811\u662f\u5426\u548c subRoot \u5b8c\u5168\u76f8\u540c&#xff1b;\u53ea\u8981\u6709\u4e00\u4e2a\u5019\u9009\u8282\u70b9\u5339\u914d\u6210\u529f&#xff0c;\u5c31\u8fd4\u56de true&#xff0c;\u5426\u5219\u8fd4\u56de false\u3002<\/p>\n<p>\u5916\u5c42\u9012\u5f52&#xff08;isSubtree&#xff09;\u7684\u5b8c\u6574\u903b\u8f91 \u7ec8\u6b62\u6761\u4ef6&#xff1a;\u5982\u679c\u5f53\u524d root \u4e3a\u7a7a&#xff0c;\u8bf4\u660e\u5df2\u7ecf\u904d\u5386\u5230\u53f6\u5b50\u8282\u70b9\u7684\u5b50\u8282\u70b9&#xff0c;\u6ca1\u6709\u5339\u914d\u53ef\u80fd&#xff0c;\u8fd4\u56de false&#xff1b; \u5f53\u524d\u8282\u70b9\u68c0\u67e5&#xff1a;\u5982\u679c\u4ee5\u5f53\u524d root \u4e3a\u6839\u7684\u5b50\u6811\u548c subRoot \u76f8\u540c&#xff08;\u8c03\u7528 isSameTree \u8fd4\u56de true&#xff09;&#xff0c;\u76f4\u63a5\u8fd4\u56de true&#xff1b; \u9012\u5f52\u904d\u5386\u5b50\u6811&#xff1a;\u5982\u679c\u5f53\u524d\u8282\u70b9\u4e0d\u5339\u914d&#xff0c;\u5c31\u9012\u5f52\u68c0\u67e5root \u7684\u5de6\u5b50\u6811\u548croot \u7684\u53f3\u5b50\u6811\u662f\u5426\u5305\u542b subRoot&#xff0c;\u53ea\u8981\u5176\u4e2d\u4e00\u4e2a\u8fd4\u56de true&#xff0c;\u6574\u4f53\u5c31\u8fd4\u56de true&#xff1b; \u6700\u7ec8\u7ed3\u679c&#xff1a;\u53ea\u6709\u6240\u6709\u8282\u70b9\u90fd\u68c0\u67e5\u8fc7\u4e14\u90fd\u4e0d\u5339\u914d&#xff0c;\u624d\u8fd4\u56de false\u3002<\/p>\n<h4>6.2.2 \u5b9e\u73b0\u4ee3\u7801 \u00a0<\/h4>\n<p>class Solution {<br \/>\n    public boolean isSubtree(TreeNode root, TreeNode subRoot) {<br \/>\n        \/\/ \u7ec8\u6b62\u6761\u4ef6&#xff1a;root\u4e3a\u7a7a&#xff0c;\u6ca1\u6709\u5b50\u6811\u80fd\u5339\u914d&#xff0c;\u8fd4\u56defalse<br \/>\n        if (root &#061;&#061; null) {<br \/>\n            return false;<br \/>\n        }<\/p>\n<p>        \/\/ \u60c5\u51b51&#xff1a;\u5f53\u524droot\u548csubRoot\u5b8c\u5168\u76f8\u540c \u2192 \u627e\u5230\u5b50\u6811&#xff0c;\u8fd4\u56detrue<br \/>\n        if (isSameTree(root, subRoot)) {<br \/>\n            return true;<br \/>\n        }<\/p>\n<p>        \/\/ \u60c5\u51b52&#xff1a;\u5f53\u524d\u8282\u70b9\u4e0d\u5339\u914d&#xff0c;\u9012\u5f52\u627e\u300c\u5de6\u5b50\u6811\u7684\u6240\u6709\u8282\u70b9\u300d\u548c\u300c\u53f3\u5b50\u6811\u7684\u6240\u6709\u8282\u70b9\u300d<br \/>\n        \/\/ \u5173\u952e&#xff1a;\u8fd9\u91cc\u8981\u8c03\u7528 isSubtree \u800c\u4e0d\u662f isSameTree&#xff01;<br \/>\n        boolean leftFind &#061; isSubtree(root.left, subRoot);  \/\/ \u9012\u5f52\u904d\u5386\u5de6\u5b50\u6811\u7684\u6240\u6709\u8282\u70b9<br \/>\n        boolean rightFind &#061; isSubtree(root.right, subRoot); \/\/ \u9012\u5f52\u904d\u5386\u53f3\u5b50\u6811\u7684\u6240\u6709\u8282\u70b9<\/p>\n<p>        \/\/ \u53ea\u8981\u5de6\/\u53f3\u5b50\u6811\u91cc\u6709\u4e00\u4e2a\u627e\u5230&#xff0c;\u5c31\u8fd4\u56detrue<br \/>\n        return leftFind || rightFind;<br \/>\n    }<\/p>\n<p>    \/\/ \u8f85\u52a9\u65b9\u6cd5&#xff1a;\u5224\u65ad\u4e24\u68f5\u6811\u662f\u5426\u5b8c\u5168\u76f8\u540c&#xff08;\u903b\u8f91\u6ca1\u95ee\u9898&#xff0c;\u590d\u7528&#xff09;<br \/>\n    private boolean isSameTree(TreeNode p, TreeNode q) {<br \/>\n        if (p &#061;&#061; null &amp;&amp; q &#061;&#061; null) return true;<br \/>\n        else if (p !&#061; null &amp;&amp; q &#061;&#061; null) return false;<br \/>\n        else if (p &#061;&#061; null &amp;&amp; q !&#061; null) return false;<br \/>\n        else if (p.val !&#061; q.val) return false;<\/p>\n<p>        boolean left &#061; isSameTree(p.left, q.left);<br \/>\n        boolean right &#061; isSameTree(p.right, q.right);<br \/>\n        return left &amp;&amp; right;<br \/>\n    }<br \/>\n} <\/p>\n<h3 style=\"background-color:transparent\">6.3 N\u53c9\u6811\u7684\u6700\u5927\u6df1\u5ea6<\/h3>\n<h4>6.3.1 \u601d\u8def<\/h4>\n<p>\u7ec8\u6b62\u6761\u4ef6&#xff1a;\u5982\u679c\u5f53\u524d\u8282\u70b9\u4e3a null&#xff08;\u7a7a\u8282\u70b9&#xff09;&#xff0c;\u6df1\u5ea6\u4e3a 0&#xff08;\u548c\u4e8c\u53c9\u6811\u4e00\u81f4&#xff09;&#xff1b; \u9012\u5f52\u903b\u8f91&#xff1a; \u521d\u59cb\u5316\u4e00\u4e2a\u53d8\u91cf curDepth \u8bb0\u5f55\u6240\u6709\u5b50\u8282\u70b9\u7684\u6700\u5927\u6df1\u5ea6&#xff08;\u521d\u59cb\u4e3a 0&#xff09;&#xff1b; \u904d\u5386\u5f53\u524d\u8282\u70b9\u7684\u6240\u6709\u5b50\u8282\u70b9&#xff0c;\u9012\u5f52\u8ba1\u7b97\u6bcf\u4e2a\u5b50\u8282\u70b9\u7684\u6df1\u5ea6&#xff0c;\u5e76\u7528 Math.max \u4fdd\u7559\u6700\u5927\u7684\u90a3\u4e2a&#xff1b; \u5408\u5e76\u7ed3\u679c&#xff1a;\u5f53\u524d\u8282\u70b9\u7684\u6df1\u5ea6 &#061; \u6240\u6709\u5b50\u8282\u70b9\u7684\u6700\u5927\u6df1\u5ea6 &#043; 1&#xff08;&#043;1 \u662f\u7b97\u4e0a\u5f53\u524d\u8282\u70b9\u672c\u8eab&#xff0c;\u548c\u4e8c\u53c9\u6811\u4e00\u81f4&#xff09;\u3002 \u7b80\u5355\u7c7b\u6bd4&#xff1a;\u4e8c\u53c9\u6811\u662f \u201c\u95ee\u5de6\u3001\u53f3\u4e24\u4e2a\u5b69\u5b50\u8c01\u7684\u6df1\u5ea6\u6df1\u201d&#xff0c;N \u53c9\u6811\u662f \u201c\u95ee\u6240\u6709\u5b69\u5b50\u8c01\u7684\u6df1\u5ea6\u6df1\u201d&#xff0c;\u6700\u540e\u52a0\u81ea\u5df1\u8fd9\u4e00\u5c42\u3002<\/p>\n<h4>6.3.2 \u5b9e\u73b0\u4ee3\u7801<\/h4>\n<p>class Solution {<br \/>\n    \/\/ \u4e3b\u65b9\u6cd5&#xff1a;\u6c42N\u53c9\u6811\u7684\u6700\u5927\u6df1\u5ea6<br \/>\n    public int maxDepth(Node root) {<br \/>\n        \/\/ \u9012\u5f52\u7ec8\u6b62\u6761\u4ef6&#xff1a;\u7a7a\u8282\u70b9\u7684\u6df1\u5ea6\u4e3a0&#xff08;\u548c\u4e8c\u53c9\u6811\u5b8c\u5168\u4e00\u81f4&#xff09;<br \/>\n        if (root &#061;&#061; null) {<br \/>\n            return 0;<br \/>\n        }<\/p>\n<p>        \/\/ \u521d\u59cb\u5316\u5f53\u524d\u8282\u70b9\u6240\u6709\u5b50\u8282\u70b9\u7684\u6700\u5927\u6df1\u5ea6\u4e3a0<br \/>\n        int curDepth &#061; 0;<\/p>\n<p>        \/\/ \u904d\u5386\u5f53\u524d\u8282\u70b9\u7684\u6240\u6709\u5b50\u8282\u70b9&#xff08;\u6838\u5fc3\u533a\u522b&#xff1a;\u4e8c\u53c9\u6811\u53ea\u904d\u5386left\/right&#xff0c;N\u53c9\u6811\u904d\u5386\u6240\u6709children&#xff09;<br \/>\n        for (int i &#061; 0; i &lt; root.children.size(); i&#043;&#043;) {<br \/>\n            \/\/ \u9012\u5f52\u8ba1\u7b97\u5f53\u524d\u5b50\u8282\u70b9\u7684\u6df1\u5ea6&#xff0c;\u5e76\u7528Math.max\u4fdd\u7559\u6700\u5927\u7684\u5b50\u8282\u70b9\u6df1\u5ea6<br \/>\n            curDepth &#061; Math.max(maxDepth(root.children.get(i)), curDepth);<br \/>\n        }<\/p>\n<p>        \/\/ \u5f53\u524d\u8282\u70b9\u7684\u6df1\u5ea6 &#061; \u6240\u6709\u5b50\u8282\u70b9\u7684\u6700\u5927\u6df1\u5ea6 &#043; 1&#xff08;\u5f53\u524d\u8282\u70b9\u672c\u8eab&#xff09;<br \/>\n        return curDepth &#043; 1;<br \/>\n    }<br \/>\n} <\/p>\n","protected":false},"excerpt":{"rendered":"<p>1 \u4eca\u65e5\u6253\u5361\u9898<br \/>\n\u7ffb\u8f6c\u4e8c\u53c9\u6811\u00a0226. \u7ffb\u8f6c\u4e8c\u53c9\u6811 &#8211; \u529b\u6263&#xff08;LeetCode&#xff09;<br \/>\n\u5bf9\u79f0\u4e8c\u53c9\u6811\u00a0101. \u5bf9\u79f0\u4e8c\u53c9\u6811 &#8211; \u529b\u6263&#xff08;LeetCode&#xff09;<br \/>\n\u4e8c\u53c9\u6811\u7684\u6700\u5927\u6df1\u5ea6\u00a0104. \u4e8c\u53c9\u6811\u7684\u6700\u5927\u6df1\u5ea6 &#8211; \u529b\u6263&#xff08;LeetCode&#xff09;<br \/>\n\u4e8c\u53c9\u6811\u7684\u6700\u5c0f\u6df1\u5ea6\u00a0111. \u4e8c\u53c9\u6811\u7684\u6700\u5c0f\u6df1\u5ea6 &#8211; \u529b\u6263&#xff08;LeetCode&#xff09;<br \/>\n2 \u7ffb\u8f6c\u4e8c\u53c9\u6811<br \/>\n2.1 \u601d\u8def<br \/>\n\u7ffb\u8f6c\u4e8c\u53c9\u6811\u7684\u672c\u8d28\u662f&amp;#xff<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[7058,6730,99,4617,427],"topic":[],"class_list":["post-66790","post","type-post","status-publish","format-standard","hentry","category-server","tag-hot100","tag-6730","tag-java","tag-4617","tag-427"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>day14 \u4ee3\u7801\u968f\u60f3\u5f55\u7b97\u6cd5\u8bad\u7ec3\u8425 \u4e8c\u53c9\u6811\u4e13\u98982 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/66790.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"day14 \u4ee3\u7801\u968f\u60f3\u5f55\u7b97\u6cd5\u8bad\u7ec3\u8425 \u4e8c\u53c9\u6811\u4e13\u98982 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"1 \u4eca\u65e5\u6253\u5361\u9898 \u7ffb\u8f6c\u4e8c\u53c9\u6811\u00a0226. \u7ffb\u8f6c\u4e8c\u53c9\u6811 - \u529b\u6263&#xff08;LeetCode&#xff09; \u5bf9\u79f0\u4e8c\u53c9\u6811\u00a0101. \u5bf9\u79f0\u4e8c\u53c9\u6811 - \u529b\u6263&#xff08;LeetCode&#xff09; \u4e8c\u53c9\u6811\u7684\u6700\u5927\u6df1\u5ea6\u00a0104. \u4e8c\u53c9\u6811\u7684\u6700\u5927\u6df1\u5ea6 - \u529b\u6263&#xff08;LeetCode&#xff09; \u4e8c\u53c9\u6811\u7684\u6700\u5c0f\u6df1\u5ea6\u00a0111. \u4e8c\u53c9\u6811\u7684\u6700\u5c0f\u6df1\u5ea6 - \u529b\u6263&#xff08;LeetCode&#xff09; 2 \u7ffb\u8f6c\u4e8c\u53c9\u6811 2.1 \u601d\u8def \u7ffb\u8f6c\u4e8c\u53c9\u6811\u7684\u672c\u8d28\u662f&amp;#xff\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/66790.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-01-27T08:04:53+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/66790.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/66790.html\",\"name\":\"day14 \u4ee3\u7801\u968f\u60f3\u5f55\u7b97\u6cd5\u8bad\u7ec3\u8425 \u4e8c\u53c9\u6811\u4e13\u98982 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-01-27T08:04:53+00:00\",\"dateModified\":\"2026-01-27T08:04:53+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/66790.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/66790.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/66790.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"day14 \u4ee3\u7801\u968f\u60f3\u5f55\u7b97\u6cd5\u8bad\u7ec3\u8425 \u4e8c\u53c9\u6811\u4e13\u98982\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"day14 \u4ee3\u7801\u968f\u60f3\u5f55\u7b97\u6cd5\u8bad\u7ec3\u8425 \u4e8c\u53c9\u6811\u4e13\u98982 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/66790.html","og_locale":"zh_CN","og_type":"article","og_title":"day14 \u4ee3\u7801\u968f\u60f3\u5f55\u7b97\u6cd5\u8bad\u7ec3\u8425 \u4e8c\u53c9\u6811\u4e13\u98982 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"1 \u4eca\u65e5\u6253\u5361\u9898 \u7ffb\u8f6c\u4e8c\u53c9\u6811\u00a0226. \u7ffb\u8f6c\u4e8c\u53c9\u6811 - \u529b\u6263&#xff08;LeetCode&#xff09; \u5bf9\u79f0\u4e8c\u53c9\u6811\u00a0101. \u5bf9\u79f0\u4e8c\u53c9\u6811 - \u529b\u6263&#xff08;LeetCode&#xff09; \u4e8c\u53c9\u6811\u7684\u6700\u5927\u6df1\u5ea6\u00a0104. \u4e8c\u53c9\u6811\u7684\u6700\u5927\u6df1\u5ea6 - \u529b\u6263&#xff08;LeetCode&#xff09; \u4e8c\u53c9\u6811\u7684\u6700\u5c0f\u6df1\u5ea6\u00a0111. \u4e8c\u53c9\u6811\u7684\u6700\u5c0f\u6df1\u5ea6 - \u529b\u6263&#xff08;LeetCode&#xff09; 2 \u7ffb\u8f6c\u4e8c\u53c9\u6811 2.1 \u601d\u8def \u7ffb\u8f6c\u4e8c\u53c9\u6811\u7684\u672c\u8d28\u662f&amp;#xff","og_url":"https:\/\/www.wsisp.com\/helps\/66790.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-01-27T08:04:53+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/66790.html","url":"https:\/\/www.wsisp.com\/helps\/66790.html","name":"day14 \u4ee3\u7801\u968f\u60f3\u5f55\u7b97\u6cd5\u8bad\u7ec3\u8425 \u4e8c\u53c9\u6811\u4e13\u98982 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-01-27T08:04:53+00:00","dateModified":"2026-01-27T08:04:53+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/66790.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/66790.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/66790.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"day14 \u4ee3\u7801\u968f\u60f3\u5f55\u7b97\u6cd5\u8bad\u7ec3\u8425 \u4e8c\u53c9\u6811\u4e13\u98982"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/66790","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=66790"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/66790\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=66790"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=66790"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=66790"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=66790"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}