{"id":121622,"date":"2026-11-03T06:08:32","date_gmt":"2026-11-02T22:08:32","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/121622.html"},"modified":"2026-11-03T06:08:32","modified_gmt":"2026-11-02T22:08:32","slug":"%e5%8a%9b%e6%89%a315%e4%b8%89%e6%95%b0%e4%b9%8b%e5%92%8c%ef%bc%88%e6%8e%92%e5%ba%8f-%e5%8f%8c%e6%8c%87%e9%92%88%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/121622.html","title":{"rendered":"\u529b\u626315\u4e09\u6570\u4e4b\u548c\uff08\u6392\u5e8f + \u53cc\u6307\u9488\uff09"},"content":{"rendered":"<p>class Solution {<br \/>\n    public List&lt;List&lt;Integer&gt;&gt; threeSum(int[] nums) {<br \/>\n        int n &#061; nums.length;<\/p>\n<p>        \/\/ \u5148\u628a\u6570\u7ec4\u5347\u5e8f\u6392\u5e8f&#xff0c;\u662f\u53cc\u6307\u9488\u7684\u524d\u63d0&#xff0c;\u65b9\u4fbf\u53bb\u91cd\u548c\u79fb\u52a8\u6307\u9488<br \/>\n        Arrays.sort(nums); <\/p>\n<p>        List&lt;List&lt;Integer&gt;&gt; ans &#061; new ArrayList&lt;List&lt;Integer&gt;&gt;(); <\/p>\n<p>        \/\/\u679a\u4e3e\u7b2c\u4e00\u4e2a\u6570<br \/>\n        for (int first &#061; 0; first &lt; n; &#043;&#043;first) {<br \/>\n            \/\/ a\u53bb\u91cd&#xff1a;\u5982\u679c\u5f53\u524da\u548c\u4e0a\u4e00\u8f6ea\u76f8\u540c&#xff0c;\u76f4\u63a5\u8df3\u8fc7&#xff0c;\u907f\u514d\u4ea7\u51fa\u4e00\u6837\u7684\u4e09\u5143\u7ec4<br \/>\n            if (first &gt; 0 &amp;&amp; nums[first] &#061;&#061; nums[first &#8211; 1]) {<br \/>\n                continue;<br \/>\n            }<\/p>\n<p>            int third &#061; n &#8211; 1; <\/p>\n<p>            \/\/ \u76ee\u6807&#xff1a;b &#043; c &#061; -a&#xff0c;\u4e5f\u5c31\u662f a&#043;b&#043;c&#061;0<br \/>\n            int target &#061; -nums[first]; <\/p>\n<p>            \/\/ \u679a\u4e3e\u7b2c\u4e8c\u4e2a\u6570<br \/>\n            for (int second &#061; first &#043; 1; second &lt; n; &#043;&#043;second) {<br \/>\n                \/\/ b\u53bb\u91cd<br \/>\n                if (second &gt; first &#043; 1 &amp;&amp; nums[second] &#061;&#061; nums[second &#8211; 1]) {<br \/>\n                    continue;<br \/>\n                }<\/p>\n<p>                \/\/ \u6838\u5fc3\u53cc\u6307\u9488&#xff1a;b&#043;c &gt; target&#xff0c;\u8bf4\u660ec\u592a\u5927\u4e86&#xff0c;c\u5de6\u79fb\u53d8\u5c0f<br \/>\n                \/\/ \u6761\u4ef6 second &lt; third&#xff1a;\u5fc5\u987b\u4fdd\u8bc1b\u5728c\u5de6\u8fb9&#xff0c;\u4e0d\u80fd\u91cd\u5408<br \/>\n                while (second &lt; third &amp;&amp; nums[second] &#043; nums[third] &gt; target) {<br \/>\n                    &#8211;third;<br \/>\n                }<\/p>\n<p>                if (second &#061;&#061; third) {<br \/>\n                    break;<br \/>\n                }<\/p>\n<p>                if (nums[second] &#043; nums[third] &#061;&#061; target) {<br \/>\n                    List&lt;Integer&gt; list &#061; new ArrayList&lt;Integer&gt;();<br \/>\n                    list.add(nums[first]);<br \/>\n                    list.add(nums[second]);<br \/>\n                    list.add(nums[third]);<br \/>\n                    ans.add(list);<br \/>\n                }<br \/>\n            }<br \/>\n        }<br \/>\n        return ans;<br \/>\n    }<br \/>\n}<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>class Solution {public List&lt;List&gt; threeSum(int[] nums) {int n  nums.length;\/\/ \u5148\u628a\u6570\u7ec4\u5347\u5e8f\u6392\u5e8f&#xff0c;\u662f\u53cc\u6307\u9488\u7684\u524d\u63d0&#xff0c;\u65b9\u4fbf\u53bb\u91cd\u548c\u79fb\u52a8\u6307\u9488Arrays.sort(nums); List&lt;List&gt; ans  new ArrayList&lt;List&gt;(); \/\/\u679a\u4e3e\u7b2c\u4e00\u4e2a\u6570for (int first  0; first &lt; n;<\/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":[2692,1813,427],"topic":[],"class_list":["post-121622","post","type-post","status-publish","format-standard","hentry","category-server","tag-leetcode","tag-1813","tag-427"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u529b\u626315\u4e09\u6570\u4e4b\u548c\uff08\u6392\u5e8f + \u53cc\u6307\u9488\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\/121622.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u529b\u626315\u4e09\u6570\u4e4b\u548c\uff08\u6392\u5e8f + \u53cc\u6307\u9488\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"class Solution {public List&lt;List&gt; threeSum(int[] nums) {int n nums.length;\/\/ \u5148\u628a\u6570\u7ec4\u5347\u5e8f\u6392\u5e8f&#xff0c;\u662f\u53cc\u6307\u9488\u7684\u524d\u63d0&#xff0c;\u65b9\u4fbf\u53bb\u91cd\u548c\u79fb\u52a8\u6307\u9488Arrays.sort(nums); List&lt;List&gt; ans new ArrayList&lt;List&gt;(); \/\/\u679a\u4e3e\u7b2c\u4e00\u4e2a\u6570for (int first 0; first &lt; n;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/121622.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-02T22:08:32+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=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/121622.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/121622.html\",\"name\":\"\u529b\u626315\u4e09\u6570\u4e4b\u548c\uff08\u6392\u5e8f + \u53cc\u6307\u9488\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-11-02T22:08:32+00:00\",\"dateModified\":\"2026-11-02T22:08:32+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/121622.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/121622.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/121622.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u529b\u626315\u4e09\u6570\u4e4b\u548c\uff08\u6392\u5e8f + \u53cc\u6307\u9488\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\u626315\u4e09\u6570\u4e4b\u548c\uff08\u6392\u5e8f + \u53cc\u6307\u9488\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\/121622.html","og_locale":"zh_CN","og_type":"article","og_title":"\u529b\u626315\u4e09\u6570\u4e4b\u548c\uff08\u6392\u5e8f + \u53cc\u6307\u9488\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"class Solution {public List&lt;List&gt; threeSum(int[] nums) {int n nums.length;\/\/ \u5148\u628a\u6570\u7ec4\u5347\u5e8f\u6392\u5e8f&#xff0c;\u662f\u53cc\u6307\u9488\u7684\u524d\u63d0&#xff0c;\u65b9\u4fbf\u53bb\u91cd\u548c\u79fb\u52a8\u6307\u9488Arrays.sort(nums); List&lt;List&gt; ans new ArrayList&lt;List&gt;(); \/\/\u679a\u4e3e\u7b2c\u4e00\u4e2a\u6570for (int first 0; first &lt; n;","og_url":"https:\/\/www.wsisp.com\/helps\/121622.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-11-02T22:08:32+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/121622.html","url":"https:\/\/www.wsisp.com\/helps\/121622.html","name":"\u529b\u626315\u4e09\u6570\u4e4b\u548c\uff08\u6392\u5e8f + \u53cc\u6307\u9488\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-11-02T22:08:32+00:00","dateModified":"2026-11-02T22:08:32+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/121622.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/121622.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/121622.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u529b\u626315\u4e09\u6570\u4e4b\u548c\uff08\u6392\u5e8f + \u53cc\u6307\u9488\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\/121622","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=121622"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/121622\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=121622"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=121622"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=121622"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=121622"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}