{"id":98203,"date":"2026-08-31T11:48:49","date_gmt":"2026-08-31T03:48:49","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/98203.html"},"modified":"2026-08-31T11:48:49","modified_gmt":"2026-08-31T03:48:49","slug":"%e6%95%b0%e6%8d%ae%e7%bb%93%e6%9e%84%e4%b8%8e%e6%95%b0%e7%bb%84%e7%9a%84%e5%9f%ba%e6%9c%ac%e4%bb%8b%e7%bb%8dleetcode-704%e9%a2%98%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/98203.html","title":{"rendered":"\u6570\u636e\u7ed3\u6784\u4e0e\u6570\u7ec4\u7684\u57fa\u672c\u4ecb\u7ecd+Leetcode 704\u9898\u89e3"},"content":{"rendered":"<h3>\u6570\u636e\u7ed3\u6784\u7684\u57fa\u672c\u4ecb\u7ecd<\/h3>\n<h4>\u4ec0\u4e48\u662f\u6570\u636e\u7ed3\u6784<\/h4>\n<p>\u6570\u636e\u7ed3\u6784\u662f\u8ba1\u7b97\u673a\u7ec4\u7ec7\u3001\u5b58\u50a8\u6570\u636e\u7684\u65b9\u5f0f&#xff0c;\u5305\u542b\u6570\u636e\u672c\u8eab\u3001\u6570\u636e\u4e4b\u95f4\u7684\u5173\u7cfb&#xff0c;\u4ee5\u53ca\u5bf9\u6570\u636e\u7684\u589e\u5220\u6539\u67e5\u64cd\u4f5c\u3002\u540c\u6837\u7684\u6570\u636e&#xff0c;\u9009\u7528\u4e0d\u540c\u6570\u636e\u7ed3\u6784&#xff0c;\u7a0b\u5e8f\u8fd0\u884c\u6548\u7387\u5dee\u522b\u5f88\u5927\u3002\u7b97\u6cd5\u662f\u89e3\u51b3\u95ee\u9898\u7684\u6b65\u9aa4&#xff0c;\u6570\u636e\u7ed3\u6784\u662f\u5b58\u653e\u6570\u636e\u7684\u5bb9\u5668&#xff0c;\u4e8c\u8005\u7d27\u5bc6\u914d\u5408\u3002<\/p>\n<h4>\u4e24\u79cd\u7269\u7406\u5b58\u50a8\u65b9\u5f0f<\/h4>\n<h5>1.\u987a\u5e8f\u5b58\u50a8<\/h5>\n<p>\u6570\u636e\u5b58\u653e\u5728\u8fde\u7eed\u7684\u5185\u5b58\u7a7a\u95f4&#xff0c;\u6bd4\u5982\u6570\u7ec4\u3001Python \u5217\u8868\u3002<br \/>\n\u4f18\u70b9&#xff1a;\u53ef\u4ee5\u901a\u8fc7\u4e0b\u6807\u76f4\u63a5\u8bbf\u95ee\u5143\u7d20&#xff0c;\u901f\u5ea6\u5feb\u3002<br \/>\n\u7f3a\u70b9&#xff1a;\u5728\u4e2d\u95f4\u4f4d\u7f6e\u63d2\u5165\u3001\u5220\u9664\u5143\u7d20&#xff0c;\u9700\u8981\u79fb\u52a8\u5f88\u591a\u6570\u636e&#xff0c;\u6548\u7387\u4f4e\u3002<\/p>\n<h5>2.\u94fe\u5f0f\u5b58\u50a8<\/h5>\n<p>\u5185\u5b58\u4e0d\u8fde\u7eed&#xff0c;\u6bcf\u4e2a\u7ed3\u70b9\u4fdd\u5b58\u6570\u636e&#xff0c;\u540c\u65f6\u8bb0\u5f55\u4e0b\u4e00\u4e2a\u7ed3\u70b9\u7684\u4f4d\u7f6e&#xff0c;\u4ee3\u8868\u5c31\u662f\u94fe\u8868\u3002<br \/>\n\u4f18\u70b9&#xff1a;\u63d2\u5165\u5220\u9664\u53ea\u4fee\u6539\u7ed3\u70b9\u6307\u5411&#xff0c;\u4e0d\u7528\u79fb\u52a8\u5927\u91cf\u6570\u636e\u3002<br \/>\n\u7f3a\u70b9&#xff1a;\u4e0d\u80fd\u76f4\u63a5\u968f\u673a\u8bbf\u95ee&#xff0c;\u67e5\u627e\u5143\u7d20\u9700\u8981\u4ece\u5934\u9010\u4e2a\u904d\u5386\u3002<\/p>\n<h4>\u903b\u8f91\u7ed3\u6784<\/h4>\n<h5>1.\u7ebf\u6027\u7ed3\u6784&#xff1a;\u4e00\u5bf9\u4e00\u7684\u5173\u7cfb&#xff08;\u5143\u7d20\u6392\u6210\u4e00\u6761\u76f4\u7ebf&#xff0c;\u9664\u5f00\u5934\u5c3e&#xff0c;\u6bcf\u4e2a\u5143\u7d20\u53ea\u6709\u4e00\u4e2a\u524d\u9a71\u548c\u540e\u7ee7&#xff09;<\/h5>\n<p>\u6570\u7ec4 \/ \u5217\u8868&#xff1a;\u57fa\u7840\u5bb9\u5668&#xff0c;\u4f9d\u9760\u4e0b\u6807\u8bbf\u95ee<br \/>\n\u94fe\u8868&#xff1a;\u5355\u94fe\u8868\u3001\u53cc\u5411\u94fe\u8868\u3001\u5faa\u73af\u94fe\u8868<br \/>\n\u6808&#xff1a;\u540e\u8fdb\u5148\u51fa&#xff0c;\u53ea\u80fd\u4ece\u540c\u4e00\u7aef\u5b58\u53d6&#xff0c;\u7528\u4e8e\u62ec\u53f7\u5339\u914d\u3001\u51fd\u6570\u8c03\u7528<br \/>\n\u961f\u5217&#xff1a;\u5148\u8fdb\u5148\u51fa&#xff0c;\u4e00\u7aef\u5b58\u4e00\u7aef\u53d6&#xff0c;\u7528\u4e8e\u4efb\u52a1\u6392\u961f\u3001\u5e7f\u5ea6\u4f18\u5148\u641c\u7d22<\/p>\n<h5>2.\u975e\u7ebf\u6027\u7ed3\u6784<\/h5>\n<p>\u6811&#xff1a;\u4e00\u5bf9\u591a&#xff08;\u4e00\u4e2a\u8282\u70b9\u5206\u51fa\u591a\u4e2a\u5b50\u8282\u70b9\u3002\u5e38\u89c1\u4e8c\u53c9\u6811\u3001\u4e8c\u53c9\u641c\u7d22\u6811&#xff09;<br \/>\n\u56fe&#xff1a;\u591a\u5bf9\u591a&#xff08;\u8282\u70b9\u4e4b\u95f4\u53ef\u4ee5\u4efb\u610f\u8fde\u63a5&#xff0c;\u8fb9\u53ef\u4ee5\u5e26\u6743\u91cd\u3001\u65b9\u5411&#xff0c;\u7528\u4e8e\u5730\u56fe\u8def\u5f84\u3001\u793e\u4ea4\u7f51\u7edc\u7b49\u573a\u666f&#xff09;<br \/>\n\u96c6\u5408&#xff1a;\u5143\u7d20\u6ca1\u6709\u987a\u5e8f&#xff0c;\u5143\u7d20\u4e0d\u53ef\u91cd\u590d\u3002<\/p>\n<h4>\u5e38\u89c1\u6570\u636e\u7ed3\u6784\u6838\u5fc3\u7279\u70b9<\/h4>\n<p>\u6570\u7ec4&#xff1a;\u8fde\u7eed\u5185\u5b58&#xff0c;\u9002\u5408\u4e8c\u5206\u3001\u6392\u5e8f\u3002<br \/>\n\u94fe\u8868&#xff1a;\u9002\u5408\u9891\u7e41\u505a\u63d2\u5165\u5220\u9664\u3002<br \/>\n\u6808&#xff1a;\u540e\u8fdb\u5148\u51fa\u3002<br \/>\n\u961f\u5217&#xff1a;\u5148\u8fdb\u5148\u51fa\u3002<br \/>\n\u4e8c\u53c9\u6811&#xff1a;\u5c42\u7ea7\u7ed3\u6784&#xff0c;\u7528\u4e8e\u641c\u7d22\u3002<br \/>\n\u56fe&#xff1a;\u8282\u70b9\u548c\u8fb9&#xff0c;\u5904\u7406\u8def\u5f84\u7c7b\u95ee\u9898\u3002<\/p>\n<h4>\u590d\u6742\u5ea6&#xff08;\u7528\u6765\u8861\u91cf\u6027\u80fd&#xff09;<\/h4>\n<h5>\u65f6\u95f4\u590d\u6742\u5ea6 O ()&#xff1a;\u63cf\u8ff0\u6570\u636e\u53d8\u591a\u7684\u65f6\u5019&#xff0c;\u7a0b\u5e8f\u8fd0\u884c\u65f6\u95f4\u589e\u957f\u7684\u8d8b\u52bf\u3002<\/h5>\n<p>O (1) \u5e38\u6570\u7ea7&#xff0c;\u4e0d\u53d7\u6570\u636e\u91cf\u5f71\u54cd<br \/>\nO (log n) \u5bf9\u6570\u7ea7&#xff0c;\u4ee3\u8868\u4e8c\u5206\u67e5\u627e&#xff0c;\u6bcf\u6b21\u820d\u5f03\u4e00\u534a\u6570\u636e<br \/>\nO (n) \u7ebf\u6027\u7ea7&#xff0c;\u9700\u8981\u904d\u5386\u5168\u90e8\u6570\u636e<br \/>\nO (nlogn)&#xff0c;\u5e38\u89c1\u9ad8\u6548\u6392\u5e8f\u7b97\u6cd5<br \/>\nO (n\u00b2)&#xff0c;\u53cc\u91cd\u5faa\u73af&#xff0c;\u6548\u7387\u8f83\u4f4e<\/p>\n<h5>\u7a7a\u95f4\u590d\u6742\u5ea6&#xff1a;\u7b97\u6cd5\u989d\u5916\u5360\u7528\u5185\u5b58\u7684\u5927\u5c0f\u3002O (1) \u4ee3\u8868\u51e0\u4e4e\u4e0d\u989d\u5916\u5f00\u8f9f\u5185\u5b58\u3002<\/h5>\n<p>\u590d\u6742\u5ea6\u53ea\u5173\u6ce8\u589e\u957f\u8d8b\u52bf&#xff0c;\u5ffd\u7565\u5e38\u6570\u3002<\/p>\n<h4>\u903b\u8f91\u7ed3\u6784\u548c\u5b58\u50a8\u7ed3\u6784\u533a\u5206<\/h4>\n<p>1.\u903b\u8f91\u7ed3\u6784\u6307\u6570\u636e\u62bd\u8c61\u51fa\u6765\u7684\u5173\u7cfb&#xff0c;\u6bd4\u5982\u6808\u903b\u8f91\u4e0a\u540e\u8fdb\u5148\u51fa&#xff1b;<br \/>\n2.\u5b58\u50a8\u7ed3\u6784\u6307\u5728\u5185\u5b58\u771f\u5b9e\u5b58\u653e\u5f62\u5f0f&#xff0c;\u6808\u65e2\u53ef\u4ee5\u6570\u7ec4\u5b9e\u73b0&#xff0c;\u4e5f\u53ef\u4ee5\u94fe\u8868\u5b9e\u73b0\u3002<\/p>\n<h3>\u6570\u7ec4\u7684\u57fa\u672c\u6982\u5ff5<\/h3>\n<h4>\u4ec0\u4e48\u662f\u6570\u7ec4<\/h4>\n<p>\u6570\u7ec4\u662f\u6700\u57fa\u7840\u7684\u7ebf\u6027\u987a\u5e8f\u5b58\u50a8\u7684\u6570\u636e\u7ed3\u6784\u3002\u628a\u591a\u4e2a\u76f8\u540c\u7c7b\u578b\u7684\u6570\u636e&#xff0c;\u5b58\u653e\u5728\u5185\u5b58\u4e2d\u4e00\u5757\u8fde\u7eed\u7684\u7a7a\u95f4\u91cc\u3002<\/p>\n<h4>\u6838\u5fc3\u7279\u70b9<\/h4>\n<p>1.\u5185\u5b58\u8fde\u7eed&#xff0c;\u6240\u6709\u5143\u7d20\u6328\u5728\u4e00\u8d77\u5b58\u653e\u3002<br \/>\n2.\u901a\u8fc7\u4e0b\u6807&#xff08;\u7d22\u5f15&#xff09;\u8bbf\u95ee\u5143\u7d20&#xff0c;\u4e0b\u6807\u4e00\u822c\u4ece0\u5f00\u59cb\u3002<br \/>\n3.\u968f\u673a\u8bbf\u95ee&#xff1a;\u77e5\u9053\u4e0b\u6807&#xff0c;\u5c31\u80fd\u76f4\u63a5\u53d6\u51fa\u5bf9\u5e94\u5143\u7d20&#xff0c;\u65f6\u95f4\u590d\u6742\u5ea6 O (1)\u3002<br \/>\n4.\u5b58\u653e\u7684\u5143\u7d20\u4e00\u822c\u8981\u6c42\u7c7b\u578b\u76f8\u540c\u3002<\/p>\n<h4>\u4e0b\u6807&#xff08;\u7d22\u5f15&#xff09;<\/h4>\n<p>\u7b2c\u4e00\u4e2a\u5143\u7d20\u4e0b\u6807\u4e3a 0&#xff0c;\u7b2c\u4e8c\u4e2a\u4e3a 1&#xff0c;\u4f9d\u6b21\u5f80\u540e\u3002<br \/>\n\u4f8b\u6570\u7ec4[5, 2, 7]<br \/>\n\u4e0b\u6807 0&#xff1a;5&#xff0c;\u4e0b\u6807 1&#xff1a;2&#xff0c;\u4e0b\u6807 2&#xff1a;7\u3002<br \/>\n\u6570\u7ec4\u957f\u5ea6\u6307\u7684\u662f\u6570\u7ec4\u91cc\u9762\u4e00\u5171\u6709\u591a\u5c11\u4e2a\u5143\u7d20\u3002<\/p>\n<h4>\u5e38\u89c1\u64cd\u4f5c\u4ee5\u53ca\u6548\u7387<\/h4>\n<p>1.\u8bfb\u53d6 \/ \u4fee\u6539\u6307\u5b9a\u4e0b\u6807\u5143\u7d20&#xff1a;O (1)&#xff0c;\u76f4\u63a5\u5b9a\u4f4d&#xff0c;\u901f\u5ea6\u5f88\u5feb\u3002<br \/>\n2.\u5c3e\u90e8\u6dfb\u52a0\u5143\u7d20&#xff1a;\u4e00\u822c\u6548\u7387\u5f88\u9ad8\u3002<br \/>\n3.\u4e2d\u95f4\u4f4d\u7f6e\u63d2\u5165\u3001\u5220\u9664\u5143\u7d20&#xff1a;O (n)\u3002<br \/>\n\u56e0\u4e3a\u5185\u5b58\u8fde\u7eed&#xff0c;\u63d2\u5165\u6216\u8005\u5220\u9664\u540e&#xff0c;\u540e\u9762\u6240\u6709\u5143\u7d20\u90fd\u9700\u8981\u6574\u4f53\u5411\u540e \/ \u5411\u524d\u79fb\u52a8\u3002\u6570\u636e\u91cf\u5927\u7684\u65f6\u5019\u6548\u7387\u4f4e\u3002<br \/>\n4.\u904d\u5386\u6570\u7ec4&#xff1a;\u4ece\u5934\u5230\u5c3e\u9010\u4e2a\u8bbf\u95ee&#xff0c;O (n)\u3002<\/p>\n<h4>\u6570\u7ec4\u4f18\u7f3a\u70b9<\/h4>\n<p>\u4f18\u70b9&#xff1a;<br \/>\n1.\u652f\u6301\u4e0b\u6807\u968f\u673a\u8bbf\u95ee&#xff0c;\u67e5\u627e\u6307\u5b9a\u4f4d\u7f6e\u901f\u5ea6\u5feb\u3002<br \/>\n2.\u5185\u5b58\u8fde\u7eed&#xff0c;\u7f13\u5b58\u53cb\u597d&#xff0c;\u904d\u5386\u901f\u5ea6\u5feb\u3002<br \/>\n\u7f3a\u70b9&#xff1a;<br \/>\n1.\u4e2d\u95f4\u63d2\u5165\u3001\u5220\u9664\u4ee3\u4ef7\u5927&#xff0c;\u9700\u8981\u79fb\u52a8\u5927\u91cf\u5143\u7d20\u3002<br \/>\n2.\u5f88\u591a\u8bed\u8a00\u6570\u7ec4\u957f\u5ea6\u56fa\u5b9a&#xff0c;\u4e00\u65e6\u521b\u5efa&#xff0c;\u4e0d\u80fd\u968f\u610f\u6269\u5bb9<\/p>\n<h3>Leetcode 704&#043;\u9898\u89e3<\/h3>\n<h4><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260831034847-6a94f99f8d383.jpg\" \/>\u9898\u89e3&#xff1a;<\/h4>\n<p>\u5728\u5347\u5e8f\u6570\u7ec4 nums \u4e2d\u5bfb\u627e\u76ee\u6807\u503c target&#xff0c;\u5bf9\u4e8e\u7279\u5b9a\u4e0b\u6807 i&#xff0c;\u6bd4\u8f83 nums[i] \u548c target \u7684\u5927\u5c0f&#xff1a;<br \/>\n1.\u5982\u679c nums[i]&#061;target&#xff0c;\u5219\u4e0b\u6807 i \u5373\u4e3a\u8981\u5bfb\u627e\u7684\u4e0b\u6807&#xff1b;<br \/>\n2.\u5982\u679c nums[i]&gt;target&#xff0c;\u5219 target \u53ea\u53ef\u80fd\u5728\u4e0b\u6807 i \u7684\u5de6\u4fa7&#xff1b;<br \/>\n3.\u5982\u679c nums[i]&lt;target&#xff0c;\u5219 target \u53ea\u53ef\u80fd\u5728\u4e0b\u6807 i \u7684\u53f3\u4fa7\u3002<\/p>\n<p>\u56e0\u4e3a\u5b9a\u4e49\u67e5\u627e\u7684\u8303\u56f4 [left,right]&#xff0c;\u6240\u4ee5\u521d\u59cb\u67e5\u627e\u8303\u56f4\u662f\u6574\u4e2a\u6570\u7ec4\u3002\u6bcf\u6b21\u53d6\u67e5\u627e\u8303\u56f4\u7684\u4e2d\u70b9 mid&#xff0c;\u6bd4\u8f83 nums[mid] \u548c target \u7684\u5927\u5c0f&#xff0c;\u5982\u679c\u76f8\u7b49\u5219 mid \u5373\u4e3a\u8981\u5bfb\u627e\u7684\u4e0b\u6807&#xff0c;\u5982\u679c\u4e0d\u76f8\u7b49\u5219\u6839\u636e nums[mid] \u548c target \u7684\u5927\u5c0f\u5173\u7cfb\u5c06\u67e5\u627e\u8303\u56f4\u7f29\u5c0f\u4e00\u534a\u3002<br \/>\n\u4e8c\u5206\u67e5\u627e\u7684\u6761\u4ef6\u662f\u67e5\u627e\u8303\u56f4\u4e0d\u4e3a\u7a7a&#xff0c;\u5373 left\u2264right\u3002\u5982\u679c target \u5728\u6570\u7ec4\u4e2d&#xff0c;\u4e8c\u5206\u67e5\u627e\u53ef\u4ee5\u4fdd\u8bc1\u627e\u5230 target&#xff0c;\u8fd4\u56de target \u5728\u6570\u7ec4\u4e2d\u7684\u4e0b\u6807\u3002\u5982\u679c target \u4e0d\u5728\u6570\u7ec4\u4e2d&#xff0c;\u5219\u5f53 left&gt;right \u65f6\u7ed3\u675f\u67e5\u627e&#xff0c;\u8fd4\u56de \u22121\u3002<\/p>\n<h4>\u5de6\u95ed\u53f3\u95ed [left, right]<\/h4>\n<p>\u533a\u95f4\u542b\u4e49&#xff1a;left \u4e0e right \u4e0b\u6807\u5bf9\u5e94\u7684\u5143\u7d20\u90fd\u53c2\u4e0e\u67e5\u627e\u3002<br \/>\nright \u521d\u59cb\u503c&#xff1a;len(nums)-1&#xff0c;\u6570\u7ec4\u6700\u540e\u4e00\u4e2a\u5143\u7d20\u4e0b\u6807\u3002<br \/>\nwhile \u5faa\u73af\u6761\u4ef6&#xff1a;left &lt;&#061; right<br \/>\n\u5f53 left \u7b49\u4e8e right&#xff0c;\u533a\u95f4\u91cc\u9762\u8fd8\u6709\u4e00\u4e2a\u6709\u6548\u7684\u5143\u7d20&#xff0c;\u9700\u8981\u6267\u884c\u5faa\u73af\u8fdb\u884c\u5224\u65ad\u3002<\/p>\n<h5>\u66f4\u65b0\u8fb9\u754c\u89c4\u5219<\/h5>\n<p>nums [mid] &gt; target \u2192 \u76ee\u6807\u5728\u5de6\u4fa7&#xff0c;right &#061; mid &#8211; 1<br \/>\nmid \u5df2\u7ecf\u6bd4\u5bf9\u5b8c\u6bd5&#xff0c;\u4e0d\u9700\u8981\u518d\u6b21\u7eb3\u5165\u67e5\u627e\u533a\u95f4\u3002<br \/>\nnums [mid] &lt; target \u2192 \u76ee\u6807\u5728\u53f3\u4fa7&#xff0c;left &#061; mid &#043; 1<\/p>\n<h4>\u5de6\u95ed\u53f3\u5f00 [left, right)<\/h4>\n<p>\u533a\u95f4\u542b\u4e49&#xff1a;\u5305\u542b left&#xff0c;\u4e0d\u5305\u542b right \u4e0b\u6807&#xff0c;right \u4ec5\u4ec5\u4f5c\u4e3a\u8fb9\u754c\u3002<br \/>\nright \u521d\u59cb\u503c&#xff1a;len(nums)&#xff0c;\u5b83\u8d85\u51fa\u6570\u7ec4\u6700\u5927\u4e0b\u6807&#xff0c;\u4e0d\u662f\u5408\u6cd5\u5143\u7d20\u3002<br \/>\nwhile \u5faa\u73af\u6761\u4ef6&#xff1a;left &lt; right<br \/>\nleft \u4e0e right \u76f8\u7b49\u65f6&#xff0c;\u533a\u95f4\u91cc\u9762\u4e0d\u5b58\u5728\u5143\u7d20&#xff0c;\u5faa\u73af\u7ec8\u6b62\u3002<\/p>\n<h5>\u66f4\u65b0\u8fb9\u754c\u89c4\u5219<\/h5>\n<p>nums [mid] &gt; target \u2192 right &#061; mid<br \/>\nmid \u4e0b\u6807\u4e0d\u5728\u65b0\u533a\u95f4&#xff0c;\u53f3\u8fb9\u754c\u76f4\u63a5\u8d4b\u503c mid\u3002<br \/>\nnums [mid] &lt; target \u2192 left &#061; mid &#043; 1<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6570\u636e\u7ed3\u6784\u7684\u57fa\u672c\u4ecb\u7ecd\u4ec0\u4e48\u662f\u6570\u636e\u7ed3\u6784\u6570\u636e\u7ed3\u6784\u662f\u8ba1\u7b97\u673a\u7ec4\u7ec7\u3001\u5b58\u50a8\u6570\u636e\u7684\u65b9\u5f0f&#xff0c;\u5305\u542b\u6570\u636e\u672c\u8eab\u3001\u6570\u636e\u4e4b\u95f4\u7684\u5173\u7cfb&#xff0c;\u4ee5\u53ca\u5bf9\u6570\u636e\u7684\u589e\u5220\u6539\u67e5\u64cd\u4f5c\u3002\u540c\u6837\u7684\u6570\u636e&#xff0c;\u9009\u7528\u4e0d\u540c\u6570\u636e\u7ed3\u6784&#xff0c;\u7a0b\u5e8f\u8fd0\u884c\u6548\u7387\u5dee\u522b\u5f88\u5927\u3002\u7b97\u6cd5\u662f\u89e3\u51b3\u95ee\u9898\u7684\u6b65\u9aa4&#xff0c;\u6570\u636e\u7ed3\u6784\u662f\u5b58\u653e\u6570\u636e\u7684\u5bb9\u5668&#xff0c;\u4e8c\u8005\u7d27\u5bc6\u914d\u5408\u3002\u4e24\u79cd\u7269\u7406\u5b58\u50a8\u65b9\u5f0f1.\u987a\u5e8f\u5b58\u50a8\u6570\u636e\u5b58\u653e\u5728\u8fde\u7eed\u7684\u5185\u5b58\u7a7a\u95f4&#xff0c;\u6bd4\u5982\u6570\u7ec4\u3001Python \u5217\u8868\u3002<br \/>\n\u4f18\u70b9&#xff1a;\u53ef\u4ee5\u901a\u8fc7\u4e0b\u6807\u76f4\u63a5\u8bbf\u95ee\u5143\u7d20&amp;#xff0<\/p>\n","protected":false},"author":2,"featured_media":98202,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[2692,81,4323],"topic":[],"class_list":["post-98203","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-leetcode","tag-python","tag-4323"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u6570\u636e\u7ed3\u6784\u4e0e\u6570\u7ec4\u7684\u57fa\u672c\u4ecb\u7ecd+Leetcode 704\u9898\u89e3 - \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\/98203.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u6570\u636e\u7ed3\u6784\u4e0e\u6570\u7ec4\u7684\u57fa\u672c\u4ecb\u7ecd+Leetcode 704\u9898\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6570\u636e\u7ed3\u6784\u7684\u57fa\u672c\u4ecb\u7ecd\u4ec0\u4e48\u662f\u6570\u636e\u7ed3\u6784\u6570\u636e\u7ed3\u6784\u662f\u8ba1\u7b97\u673a\u7ec4\u7ec7\u3001\u5b58\u50a8\u6570\u636e\u7684\u65b9\u5f0f&#xff0c;\u5305\u542b\u6570\u636e\u672c\u8eab\u3001\u6570\u636e\u4e4b\u95f4\u7684\u5173\u7cfb&#xff0c;\u4ee5\u53ca\u5bf9\u6570\u636e\u7684\u589e\u5220\u6539\u67e5\u64cd\u4f5c\u3002\u540c\u6837\u7684\u6570\u636e&#xff0c;\u9009\u7528\u4e0d\u540c\u6570\u636e\u7ed3\u6784&#xff0c;\u7a0b\u5e8f\u8fd0\u884c\u6548\u7387\u5dee\u522b\u5f88\u5927\u3002\u7b97\u6cd5\u662f\u89e3\u51b3\u95ee\u9898\u7684\u6b65\u9aa4&#xff0c;\u6570\u636e\u7ed3\u6784\u662f\u5b58\u653e\u6570\u636e\u7684\u5bb9\u5668&#xff0c;\u4e8c\u8005\u7d27\u5bc6\u914d\u5408\u3002\u4e24\u79cd\u7269\u7406\u5b58\u50a8\u65b9\u5f0f1.\u987a\u5e8f\u5b58\u50a8\u6570\u636e\u5b58\u653e\u5728\u8fde\u7eed\u7684\u5185\u5b58\u7a7a\u95f4&#xff0c;\u6bd4\u5982\u6570\u7ec4\u3001Python \u5217\u8868\u3002 \u4f18\u70b9&#xff1a;\u53ef\u4ee5\u901a\u8fc7\u4e0b\u6807\u76f4\u63a5\u8bbf\u95ee\u5143\u7d20&amp;#xff0\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/98203.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-31T03:48:49+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260831034847-6a94f99f8d383.jpg\" \/>\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\/98203.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/98203.html\",\"name\":\"\u6570\u636e\u7ed3\u6784\u4e0e\u6570\u7ec4\u7684\u57fa\u672c\u4ecb\u7ecd+Leetcode 704\u9898\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-31T03:48:49+00:00\",\"dateModified\":\"2026-08-31T03:48:49+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/98203.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/98203.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/98203.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u6570\u636e\u7ed3\u6784\u4e0e\u6570\u7ec4\u7684\u57fa\u672c\u4ecb\u7ecd+Leetcode 704\u9898\u89e3\"}]},{\"@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":"\u6570\u636e\u7ed3\u6784\u4e0e\u6570\u7ec4\u7684\u57fa\u672c\u4ecb\u7ecd+Leetcode 704\u9898\u89e3 - \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\/98203.html","og_locale":"zh_CN","og_type":"article","og_title":"\u6570\u636e\u7ed3\u6784\u4e0e\u6570\u7ec4\u7684\u57fa\u672c\u4ecb\u7ecd+Leetcode 704\u9898\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6570\u636e\u7ed3\u6784\u7684\u57fa\u672c\u4ecb\u7ecd\u4ec0\u4e48\u662f\u6570\u636e\u7ed3\u6784\u6570\u636e\u7ed3\u6784\u662f\u8ba1\u7b97\u673a\u7ec4\u7ec7\u3001\u5b58\u50a8\u6570\u636e\u7684\u65b9\u5f0f&#xff0c;\u5305\u542b\u6570\u636e\u672c\u8eab\u3001\u6570\u636e\u4e4b\u95f4\u7684\u5173\u7cfb&#xff0c;\u4ee5\u53ca\u5bf9\u6570\u636e\u7684\u589e\u5220\u6539\u67e5\u64cd\u4f5c\u3002\u540c\u6837\u7684\u6570\u636e&#xff0c;\u9009\u7528\u4e0d\u540c\u6570\u636e\u7ed3\u6784&#xff0c;\u7a0b\u5e8f\u8fd0\u884c\u6548\u7387\u5dee\u522b\u5f88\u5927\u3002\u7b97\u6cd5\u662f\u89e3\u51b3\u95ee\u9898\u7684\u6b65\u9aa4&#xff0c;\u6570\u636e\u7ed3\u6784\u662f\u5b58\u653e\u6570\u636e\u7684\u5bb9\u5668&#xff0c;\u4e8c\u8005\u7d27\u5bc6\u914d\u5408\u3002\u4e24\u79cd\u7269\u7406\u5b58\u50a8\u65b9\u5f0f1.\u987a\u5e8f\u5b58\u50a8\u6570\u636e\u5b58\u653e\u5728\u8fde\u7eed\u7684\u5185\u5b58\u7a7a\u95f4&#xff0c;\u6bd4\u5982\u6570\u7ec4\u3001Python \u5217\u8868\u3002 \u4f18\u70b9&#xff1a;\u53ef\u4ee5\u901a\u8fc7\u4e0b\u6807\u76f4\u63a5\u8bbf\u95ee\u5143\u7d20&amp;#xff0","og_url":"https:\/\/www.wsisp.com\/helps\/98203.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-31T03:48:49+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260831034847-6a94f99f8d383.jpg"}],"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\/98203.html","url":"https:\/\/www.wsisp.com\/helps\/98203.html","name":"\u6570\u636e\u7ed3\u6784\u4e0e\u6570\u7ec4\u7684\u57fa\u672c\u4ecb\u7ecd+Leetcode 704\u9898\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-31T03:48:49+00:00","dateModified":"2026-08-31T03:48:49+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/98203.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/98203.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/98203.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u6570\u636e\u7ed3\u6784\u4e0e\u6570\u7ec4\u7684\u57fa\u672c\u4ecb\u7ecd+Leetcode 704\u9898\u89e3"}]},{"@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\/98203","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=98203"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/98203\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/98202"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=98203"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=98203"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=98203"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=98203"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}