{"id":76499,"date":"2026-02-22T15:58:29","date_gmt":"2026-02-22T07:58:29","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/76499.html"},"modified":"2026-02-22T15:58:29","modified_gmt":"2026-02-22T07:58:29","slug":"%e5%8a%9b%e6%89%a3hot100%ef%bc%9at-42-%e6%8e%a5%e9%9b%a8%e6%b0%b4%ef%bd%9c%e8%be%85%e5%8a%a9%e6%95%b0%e7%bb%84%e6%b3%95or%e5%8f%8c%e6%8c%87%e9%92%88%e6%b3%95%e7%ae%97%e6%b3%95%e5%ae%9e%e7%8e%b0","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/76499.html","title":{"rendered":"\u529b\u6263HOT100\uff1aT.42 \u63a5\u96e8\u6c34\uff5c\u8f85\u52a9\u6570\u7ec4\u6cd5or\u53cc\u6307\u9488\u6cd5\u7b97\u6cd5\u5b9e\u73b0\u7b14\u8bb0\u53ca\u6253\u5361\uff0812\/100\uff09"},"content":{"rendered":"<h2>\u3010\u529b\u6263hot100\u3011\u3010LeetCode 42\u3011\u63a5\u96e8\u6c34&#xff5c;\u8f85\u52a9\u6570\u7ec4\u6cd5or\u53cc\u6307\u9488\u6cd5<\/h2>\n<p>\u7ed9\u5b9a n \u4e2a\u975e\u8d1f\u6574\u6570\u8868\u793a\u6bcf\u4e2a\u5bbd\u5ea6\u4e3a 1 \u7684\u67f1\u5b50\u7684\u9ad8\u5ea6\u56fe&#xff0c;\u8ba1\u7b97\u6309\u6b64\u6392\u5217\u7684\u67f1\u5b50&#xff0c;\u4e0b\u96e8\u4e4b\u540e\u80fd\u63a5\u591a\u5c11\u96e8\u6c34\u3002<\/p>\n<p>\u793a\u4f8b 1&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260222075827-699ab723dd6da.png\" alt=\"img\" \/><\/p>\n<p>\u8f93\u5165&#xff1a;height &#061; [0,1,0,2,1,0,1,3,2,1,2,1]<br \/>\n\u8f93\u51fa&#xff1a;6<br \/>\n\u89e3\u91ca&#xff1a;\u4e0a\u9762\u662f\u7531\u6570\u7ec4 [0,1,0,2,1,0,1,3,2,1,2,1] \u8868\u793a\u7684\u9ad8\u5ea6\u56fe&#xff0c;\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b&#xff0c;\u53ef\u4ee5\u63a5 6 \u4e2a\u5355\u4f4d\u7684\u96e8\u6c34&#xff08;\u84dd\u8272\u90e8\u5206\u8868\u793a\u96e8\u6c34&#xff09;\u3002 <\/p>\n<p>\u793a\u4f8b 2&#xff1a;<\/p>\n<p>\u8f93\u5165&#xff1a;height &#061; [4,2,0,3,2,5]<br \/>\n\u8f93\u51fa&#xff1a;9<\/p>\n<p>\u63d0\u793a&#xff1a;<\/p>\n<ul>\n<li>n &#061;&#061; height.length<\/li>\n<li>1 &lt;&#061; n &lt;&#061; 2 * 104<\/li>\n<li>0 &lt;&#061; height[i] &lt;&#061; 105<\/li>\n<\/ul>\n<h5>1. \u8f85\u52a9\u6570\u7ec4\u6cd5&#xff08;\u66b4\u529b\u89e3\u6cd5&#xff09;<\/h5>\n<p>\u5982\u56fe\u5b9e\u4f8b1\u6240\u793a&#xff0c;\u6700\u5927\u63a5\u6c34\u91cf\u4e3a6\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260222075827-699ab723f2a96.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u4f8b\u5982&#xff0c;\u4e0b\u6807\u4e3a4\u7684\u533a\u57df&#xff0c;\u67f1\u5b50\u9ad8\u5ea6\u4e3a1&#xff0c;\u800c\u5176\u5de6\u4fa7\u6700\u9ad8\u9ad8\u5ea6\u4e3a2&#xff08;\u4e0b\u68073&#xff09;&#xff0c;\u5176\u53f3\u4fa7\u6700\u9ad8\u9ad8\u5ea6\u4e3a3&#xff08;\u4e0b\u68077&#xff09;&#xff0c;\u6c34\u4e0d\u53ef\u80fd\u6bd4\u6700\u4f4e\u7684\u67f1\u5b50\u8fd8\u8981\u9ad8&#xff08;\u6728\u6876\u6548\u5e94&#xff09;&#xff0c;\u6545\u4e0b\u68074\u7684\u63a5\u6c34\u91cf\u4e3a\u6c34\u9ad8-\u67f1\u9ad8 &#061; 2 &#8211; 1 &#061; 1&#xff1b;<\/p>\n<p>\u518d\u4f8b\u5982&#xff0c;\u4e0b\u6807\u4e3a5\u7684\u533a\u57df&#xff0c;\u67f1\u9ad8\u4e3a0&#xff0c;\u800c\u5176\u5de6\u4fa7\u6700\u9ad8\u9ad8\u5ea6\u4e3a2&#xff08;\u4e0b\u68073&#xff09;&#xff0c;\u5176\u53f3\u4fa7\u6700\u9ad8\u9ad8\u5ea6\u4e3a3&#xff08;\u4e0b\u68077&#xff09;&#xff0c;\u540c\u6837\u7684\u539f\u7406&#xff0c;\u6545\u4e0b\u68075\u7684\u63a5\u6c34\u91cf\u4e3a\u6c34\u9ad8-\u67f1\u9ad8 &#061; 2 &#8211; 0 &#061; 2.<\/p>\n<p>\u4f9d\u6b21\u7c7b\u63a8&#xff0c;\u4e0d\u59a8\u5f97\u5230<\/p>\n<p>water[i] &#061; min(left_max[i] &#8211; right_max[i]) &#8211; height[i];<\/p>\n<p>*\u601d\u8def&#xff1a;*\u4ece\u5de6\u5230\u53f3&#xff0c;\u4ece\u53f3\u5230\u5de6&#xff0c;\u4f9d\u6b21\u904d\u5386&#xff0c;\u627e\u6bcf\u4e2a\u4f4d\u7f6e\u627e\u5de6\u53f3\u6700\u5927\u503c <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260222075828-699ab72411d8c.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>*\u65f6\u95f4\/\u7a7a\u95f4\u590d\u6742\u5ea6&#xff1a;*O(n)\u3001O(n)<\/p>\n<p>\u53c2\u8003\u4ee3\u7801\u5982\u4e0b<\/p>\n<p>#include &lt;vector&gt;<br \/>\n#include &lt;algorithm&gt; \/\/ \u7528\u4e8emax\/min\u51fd\u6570<\/p>\n<p>using namespace std;<\/p>\n<p>class Solution {<br \/>\npublic:<br \/>\n    int trap(vector&lt;int&gt;&amp; height) {<br \/>\n        \/\/ \u81f3\u5c11\u9700\u89813\u4e2a\u5143\u7d20\u624d\u80fd\u5f62\u6210\u51f9\u9677\u63a5\u6c34<br \/>\n        if (height.size() &lt; 3) {<br \/>\n            return 0;<br \/>\n        }<\/p>\n<p>        int n &#061; height.size();<br \/>\n        vector&lt;int&gt; left_max(n, 0);  \/\/ \u5b58\u50a8\u6bcf\u4e2a\u4f4d\u7f6e\u5de6\u4fa7\u7684\u6700\u5927\u9ad8\u5ea6<br \/>\n        vector&lt;int&gt; right_max(n, 0); \/\/ \u5b58\u50a8\u6bcf\u4e2a\u4f4d\u7f6e\u53f3\u4fa7\u7684\u6700\u5927\u9ad8\u5ea6<br \/>\n        int ans &#061; 0; \/\/\u63a5\u6c34\u91cf<\/p>\n<p>        \/\/ \u7b2c\u4e00\u6b65&#xff1a;\u586b\u5145left_max\u6570\u7ec4<br \/>\n        for (int i &#061; 1; i &lt; n; &#043;&#043;i) {<br \/>\n            left_max[i] &#061; max(left_max[i-1], height[i-1]);<br \/>\n        }<\/p>\n<p>        \/\/ \u7b2c\u4e8c\u6b65&#xff1a;\u586b\u5145right_max\u6570\u7ec4<br \/>\n        for (int i &#061; n &#8211; 2; i &gt;&#061; 0; &#8211;i) {<br \/>\n            right_max[i] &#061; max(right_max[i&#043;1], height[i&#043;1]);<br \/>\n        }<\/p>\n<p>        \/\/ \u7b2c\u4e09\u6b65&#xff1a;\u8ba1\u7b97\u603b\u63a5\u6c34\u91cf<br \/>\n        for (int i &#061; 0; i &lt; n; &#043;&#043;i) {<br \/>\n            \/\/ \u5f53\u524d\u4f4d\u7f6e\u80fd\u63a5\u7684\u6c34\u91cf &#061; \u5de6\u53f3\u6700\u5927\u9ad8\u5ea6\u7684\u8f83\u5c0f\u503c &#8211; \u81ea\u8eab\u9ad8\u5ea6&#xff08;\u975e\u8d1f&#xff09;<br \/>\n            int current_water &#061; min(left_max[i], right_max[i]) &#8211; height[i];<br \/>\n            ans &#043;&#061; max(current_water, 0); \/\/ \u907f\u514d\u8d1f\u6570\u7d2f\u52a0<br \/>\n        }<\/p>\n<p>        return ans;<br \/>\n    }<br \/>\n};<\/p>\n<h5>1.2 \u53cc\u6307\u9488\u6cd5&#xff08;\u4f18\u5316\u89e3\u6cd5&#xff09;<\/h5>\n<p>\u4e0d\u5fc5\u6bcf\u6b21\u90fd\u91cd\u65b0\u627e\u5de6\u53f3\u6700\u5927\u503c&#xff0c;\u901a\u8fc7\u53cc\u6307\u9488&#xff08;left \u4ece\u5de6\u3001right \u4ece\u53f3&#xff09;\u904d\u5386\u6570\u7ec4&#xff0c;\u7528 pre_max \u8bb0\u5f55\u5de6\u6307\u9488\u904d\u5386\u8fc7\u7684\u6700\u5927\u9ad8\u5ea6&#xff0c;sub_max \u8bb0\u5f55\u53f3\u6307\u9488\u904d\u5386\u8fc7\u7684\u6700\u5927\u9ad8\u5ea6&#xff0c;\u6bcf\u6b21\u9009\u62e9 pre_max \u548c sub_max \u8f83\u5c0f\u7684\u4e00\u4fa7\u8ba1\u7b97\u63a5\u6c34\u91cf&#xff0c;\u6700\u7ec8\u7d2f\u52a0\u5f97\u5230\u603b\u63a5\u6c34\u91cf&#xff0c;<\/p>\n<p>\u65f6\u95f4\u590d\u6742\u5ea6 O (n)&#xff0c;\u7a7a\u95f4\u590d\u6742\u5ea6 O (1)\u3002<\/p>\n<p>class Solution {<br \/>\npublic:<br \/>\n    int trap(vector&lt;int&gt;&amp; height) {<br \/>\n        int n &#061; height.size();<br \/>\n        int ans &#061; 0;<br \/>\n        int left &#061; 0, right &#061; height.size() &#8211; 1; \/\/\u5de6\u3001\u53f3\u6307\u9488<br \/>\n        int pre_max &#061; 0, sub_max &#061; 0; \/\/\u524d\u7f00\u548c\u540e\u7f00\u7684\u6700\u5927\u503c<br \/>\n        while (left &lt;&#061; right){<br \/>\n            pre_max &#061; max(pre_max, height[left]); \/\/\u627e\u524d\u7f00\u6700\u5927\u503c<br \/>\n            sub_max &#061; max(sub_max, height[right]); \/\/\u627e\u540e\u7f00\u6700\u5927\u503c<br \/>\n            if (pre_max &lt; sub_max){<br \/>\n                ans &#043;&#061; pre_max &#8211; height[left]; \/\/\u66f4\u65b0\u6700\u5927\u63a5\u6c34\u5bb9\u91cf<br \/>\n                left &#043;&#061; 1;<br \/>\n            }else{<br \/>\n                ans &#043;&#061; sub_max &#8211; height[right]; \/\/\u66f4\u65b0\u6700\u5927\u63a5\u6c34\u5bb9\u91cf<br \/>\n                right -&#061; 1;<br \/>\n            }<br \/>\n        }<br \/>\n        return ans;<\/p>\n<p>    }<br \/>\n};<\/p>\n<p>\u8f85\u52a9\u6570\u7ec4\u6cd5\u56fe&#xff1a;B\u7ad9&#064;\u6ce2\u6ce2\u5fae\u8bfe<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3010\u529b\u6263hot100\u3011\u3010LeetCode 42\u3011\u63a5\u96e8\u6c34&#xff5c;\u8f85\u52a9\u6570\u7ec4\u6cd5or\u53cc\u6307\u9488\u6cd5<br \/>\n\u7ed9\u5b9a n \u4e2a\u975e\u8d1f\u6574\u6570\u8868\u793a\u6bcf\u4e2a\u5bbd\u5ea6\u4e3a 1 \u7684\u67f1\u5b50\u7684\u9ad8\u5ea6\u56fe&#xff0c;\u8ba1\u7b97\u6309\u6b64\u6392\u5217\u7684\u67f1\u5b50&#xff0c;\u4e0b\u96e8\u4e4b\u540e\u80fd\u63a5\u591a\u5c11\u96e8\u6c34\u3002<br \/>\n\u793a\u4f8b 1&#xff1a; \u8f93\u5165&#xff1a;height  [0,1,0,2,1,0,1,3,2,1,2,1]<br \/>\n\u8f93\u51fa&#xff1a;6<br \/>\n\u89e3\u91ca&#xff1a;\u4e0a\u9762\u662f\u7531\u6570\u7ec4 [0,1,0,2,1,0,1,3,2,1,2,1] \u8868\u793a\u7684\u9ad8\u5ea6\u56fe&#xff0c;\u5728\u8fd9<\/p>\n","protected":false},"author":2,"featured_media":76496,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[2692,305,427],"topic":[],"class_list":["post-76499","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-leetcode","tag-305","tag-427"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u529b\u6263HOT100\uff1aT.42 \u63a5\u96e8\u6c34\uff5c\u8f85\u52a9\u6570\u7ec4\u6cd5or\u53cc\u6307\u9488\u6cd5\u7b97\u6cd5\u5b9e\u73b0\u7b14\u8bb0\u53ca\u6253\u5361\uff0812\/100\uff09 - \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\/76499.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u529b\u6263HOT100\uff1aT.42 \u63a5\u96e8\u6c34\uff5c\u8f85\u52a9\u6570\u7ec4\u6cd5or\u53cc\u6307\u9488\u6cd5\u7b97\u6cd5\u5b9e\u73b0\u7b14\u8bb0\u53ca\u6253\u5361\uff0812\/100\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u3010\u529b\u6263hot100\u3011\u3010LeetCode 42\u3011\u63a5\u96e8\u6c34&#xff5c;\u8f85\u52a9\u6570\u7ec4\u6cd5or\u53cc\u6307\u9488\u6cd5 \u7ed9\u5b9a n \u4e2a\u975e\u8d1f\u6574\u6570\u8868\u793a\u6bcf\u4e2a\u5bbd\u5ea6\u4e3a 1 \u7684\u67f1\u5b50\u7684\u9ad8\u5ea6\u56fe&#xff0c;\u8ba1\u7b97\u6309\u6b64\u6392\u5217\u7684\u67f1\u5b50&#xff0c;\u4e0b\u96e8\u4e4b\u540e\u80fd\u63a5\u591a\u5c11\u96e8\u6c34\u3002 \u793a\u4f8b 1&#xff1a; \u8f93\u5165&#xff1a;height [0,1,0,2,1,0,1,3,2,1,2,1] \u8f93\u51fa&#xff1a;6 \u89e3\u91ca&#xff1a;\u4e0a\u9762\u662f\u7531\u6570\u7ec4 [0,1,0,2,1,0,1,3,2,1,2,1] \u8868\u793a\u7684\u9ad8\u5ea6\u56fe&#xff0c;\u5728\u8fd9\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/76499.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-02-22T07:58:29+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260222075827-699ab723dd6da.png\" \/>\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=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/76499.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/76499.html\",\"name\":\"\u529b\u6263HOT100\uff1aT.42 \u63a5\u96e8\u6c34\uff5c\u8f85\u52a9\u6570\u7ec4\u6cd5or\u53cc\u6307\u9488\u6cd5\u7b97\u6cd5\u5b9e\u73b0\u7b14\u8bb0\u53ca\u6253\u5361\uff0812\/100\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-02-22T07:58:29+00:00\",\"dateModified\":\"2026-02-22T07:58:29+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/76499.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/76499.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/76499.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u529b\u6263HOT100\uff1aT.42 \u63a5\u96e8\u6c34\uff5c\u8f85\u52a9\u6570\u7ec4\u6cd5or\u53cc\u6307\u9488\u6cd5\u7b97\u6cd5\u5b9e\u73b0\u7b14\u8bb0\u53ca\u6253\u5361\uff0812\/100\uff09\"}]},{\"@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":"\u529b\u6263HOT100\uff1aT.42 \u63a5\u96e8\u6c34\uff5c\u8f85\u52a9\u6570\u7ec4\u6cd5or\u53cc\u6307\u9488\u6cd5\u7b97\u6cd5\u5b9e\u73b0\u7b14\u8bb0\u53ca\u6253\u5361\uff0812\/100\uff09 - \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\/76499.html","og_locale":"zh_CN","og_type":"article","og_title":"\u529b\u6263HOT100\uff1aT.42 \u63a5\u96e8\u6c34\uff5c\u8f85\u52a9\u6570\u7ec4\u6cd5or\u53cc\u6307\u9488\u6cd5\u7b97\u6cd5\u5b9e\u73b0\u7b14\u8bb0\u53ca\u6253\u5361\uff0812\/100\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u3010\u529b\u6263hot100\u3011\u3010LeetCode 42\u3011\u63a5\u96e8\u6c34&#xff5c;\u8f85\u52a9\u6570\u7ec4\u6cd5or\u53cc\u6307\u9488\u6cd5 \u7ed9\u5b9a n \u4e2a\u975e\u8d1f\u6574\u6570\u8868\u793a\u6bcf\u4e2a\u5bbd\u5ea6\u4e3a 1 \u7684\u67f1\u5b50\u7684\u9ad8\u5ea6\u56fe&#xff0c;\u8ba1\u7b97\u6309\u6b64\u6392\u5217\u7684\u67f1\u5b50&#xff0c;\u4e0b\u96e8\u4e4b\u540e\u80fd\u63a5\u591a\u5c11\u96e8\u6c34\u3002 \u793a\u4f8b 1&#xff1a; \u8f93\u5165&#xff1a;height [0,1,0,2,1,0,1,3,2,1,2,1] \u8f93\u51fa&#xff1a;6 \u89e3\u91ca&#xff1a;\u4e0a\u9762\u662f\u7531\u6570\u7ec4 [0,1,0,2,1,0,1,3,2,1,2,1] \u8868\u793a\u7684\u9ad8\u5ea6\u56fe&#xff0c;\u5728\u8fd9","og_url":"https:\/\/www.wsisp.com\/helps\/76499.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-02-22T07:58:29+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260222075827-699ab723dd6da.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/76499.html","url":"https:\/\/www.wsisp.com\/helps\/76499.html","name":"\u529b\u6263HOT100\uff1aT.42 \u63a5\u96e8\u6c34\uff5c\u8f85\u52a9\u6570\u7ec4\u6cd5or\u53cc\u6307\u9488\u6cd5\u7b97\u6cd5\u5b9e\u73b0\u7b14\u8bb0\u53ca\u6253\u5361\uff0812\/100\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-02-22T07:58:29+00:00","dateModified":"2026-02-22T07:58:29+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/76499.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/76499.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/76499.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u529b\u6263HOT100\uff1aT.42 \u63a5\u96e8\u6c34\uff5c\u8f85\u52a9\u6570\u7ec4\u6cd5or\u53cc\u6307\u9488\u6cd5\u7b97\u6cd5\u5b9e\u73b0\u7b14\u8bb0\u53ca\u6253\u5361\uff0812\/100\uff09"}]},{"@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\/76499","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=76499"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/76499\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/76496"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=76499"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=76499"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=76499"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=76499"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}