{"id":5602,"date":"2023-11-27T19:14:40","date_gmt":"2023-11-27T11:14:40","guid":{"rendered":"https:\/\/white-night.club\/?p=5602"},"modified":"2024-02-22T19:24:20","modified_gmt":"2024-02-22T11:24:20","slug":"ad165","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/11\/27\/ad165\/","title":{"rendered":"283.\u00a0\u79fb\u52a8\u96f6"},"content":{"rendered":"\n<p>\u7ed9\u5b9a\u4e00\u4e2a\u6570\u7ec4&nbsp;<code>nums<\/code>\uff0c\u7f16\u5199\u4e00\u4e2a\u51fd\u6570\u5c06\u6240\u6709&nbsp;<code>0<\/code>&nbsp;\u79fb\u52a8\u5230\u6570\u7ec4\u7684\u672b\u5c3e\uff0c\u540c\u65f6\u4fdd\u6301\u975e\u96f6\u5143\u7d20\u7684\u76f8\u5bf9\u987a\u5e8f\u3002<\/p>\n\n\n\n<p><strong>\u8bf7\u6ce8\u610f<\/strong>&nbsp;\uff0c\u5fc5\u987b\u5728\u4e0d\u590d\u5236\u6570\u7ec4\u7684\u60c5\u51b5\u4e0b\u539f\u5730\u5bf9\u6570\u7ec4\u8fdb\u884c\u64cd\u4f5c\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 1:<\/strong><strong>\u8f93\u5165:<\/strong> nums = <code>[0,1,0,3,12]<\/code><strong>\u8f93\u51fa:<\/strong><code>[1,3,12,0,0]<\/code><\/p>\n\n\n\n<p><strong>\u793a\u4f8b 2:<\/strong><strong>\u8f93\u5165:<\/strong> nums = <code>[0]<\/code><strong>\u8f93\u51fa:<\/strong><code>[0]<\/code><\/p>\n\n\n\n<p><strong>\u63d0\u793a<\/strong>:<\/p>\n\n\n\n<ul>\n<li><code>1 &lt;= nums.length &lt;= 10<sup>4<\/sup><\/code><\/li>\n\n\n\n<li><code>-2<sup>31<\/sup>&nbsp;&lt;= nums[i] &lt;= 2<sup>31<\/sup>&nbsp;- 1<\/code><\/li>\n<\/ul>\n\n\n\n<p><strong>\u8fdb\u9636\uff1a<\/strong>\u4f60\u80fd\u5c3d\u91cf\u51cf\u5c11\u5b8c\u6210\u7684\u64cd\u4f5c\u6b21\u6570\u5417\uff1f<\/p>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color has-link-color wp-elements-db7d1dcdabd125fe3cb1cd106e289972\">\n<p>\u89e3\u9898\u601d\u8def<\/p>\n<cite><em>\u53cc\u6307\u9488<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u4e0e\u5176\u4ece\u201c\u628a0\u5f80\u540e\u6392\u201d\u5165\u624b\uff0c\u4e0d\u5982\u4ece\u628a\u975e0\u6570\u5f80\u524d\u6392\u5165\u624b\u3002<\/p>\n\n\n\n<p>\u8fd9\u91cc\u672c\u6765\u60f3\u7528\u5f02\u6216\u6765\u4ea4\u6362\u6570\u636e\uff0c\u4f46\u8c8c\u4f3c\u4e0d\u592a\u884c\u3002<\/p>\n\n\n\n<p>\u5f53\u6570\u7ec4\u53ea\u6709\u4e00\u4e2a\u5143\u7d201\u7684\u65f6\u5019\uff0c1^1=0\u3002\u7531\u4e8e\u5de6\u53f3\u6307\u9488\u90fd\u6307\u5411\u7684\u540c\u4e00\u4e2a\u503c\uff0c\u4e24\u4e2a\u503c\u6b64\u65f6\u90fd\u4e3a0\u3002\u6b64\u65f6\u518d\u5f02\u6216\u5c31\u662f0^0=0\uff0c\u518d\u5f02\u6216\u4e00\u6b21\u8fd8\u662f0^0=0\u3002\u4e0d\u8fc7\u8bbe\u4e2a\u4e34\u65f6\u53d8\u91cf\u4fdd\u5b58\u4e0b\u503c\uff0c\u5e94\u8be5\u5012\u4e5f\u4e0d\u662f\u4e0d\u884c\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2b2b2b;color:#c7c7c7\">Go<\/span><span role=\"button\" tabindex=\"0\" data-code=\"func moveZeroes(nums []int)  {\n    left:=0\n    for right:=0;right&lt;len(nums);{\n        if nums[right]!=0{\n            nums[left],nums[right]=nums[right],nums[left]\n            left++\n        }\n        right++\n    }\n}\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #569CD6\">func<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #DCDCAA\">moveZeroes<\/span><span style=\"color: #D4D4D4\">(nums []<\/span><span style=\"color: #4EC9B0\">int<\/span><span style=\"color: #D4D4D4\">)  {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #9CDCFE\">left<\/span><span style=\"color: #D4D4D4\">:=<\/span><span style=\"color: #B5CEA8\">0<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #C586C0\">for<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #9CDCFE\">right<\/span><span style=\"color: #D4D4D4\">:=<\/span><span style=\"color: #B5CEA8\">0<\/span><span style=\"color: #D4D4D4\">;right&lt;<\/span><span style=\"color: #DCDCAA\">len<\/span><span style=\"color: #D4D4D4\">(nums);{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> nums[right]!=<\/span><span style=\"color: #B5CEA8\">0<\/span><span style=\"color: #D4D4D4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">            nums[left],nums[right]=nums[right],nums[left]<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">            left++<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        right++<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">}<\/span><\/span><\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1a\u53cc\u6307\u9488<\/p>\n","protected":false},"author":1,"featured_media":2827,"comment_status":"open","ping_status":"","sticky":false,"template":"base","format":"standard","meta":{"footnotes":""},"categories":[42,25],"tags":[38],"_links":{"self":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/5602"}],"collection":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/comments?post=5602"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/5602\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media\/2827"}],"wp:attachment":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media?parent=5602"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=5602"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=5602"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}