{"id":2211,"date":"2022-01-21T10:42:49","date_gmt":"2022-01-21T02:42:49","guid":{"rendered":"http:\/\/139.9.1.231\/?p=2211"},"modified":"2022-01-21T10:42:49","modified_gmt":"2022-01-21T02:42:49","slug":"leetcodeday45","status":"publish","type":"post","link":"http:\/\/139.9.1.231\/index.php\/2022\/01\/21\/leetcodeday45\/","title":{"rendered":"leetcodeday45 &#8211;\u8df3\u8dc3\u6e38\u620f"},"content":{"rendered":"\n<p>\u7ed9\u4f60\u4e00\u4e2a\u975e\u8d1f\u6574\u6570\u6570\u7ec4&nbsp;<code>nums<\/code>&nbsp;\uff0c\u4f60\u6700\u521d\u4f4d\u4e8e\u6570\u7ec4\u7684\u7b2c\u4e00\u4e2a\u4f4d\u7f6e\u3002<\/p>\n\n\n\n<p>\u6570\u7ec4\u4e2d\u7684\u6bcf\u4e2a\u5143\u7d20\u4ee3\u8868\u4f60\u5728\u8be5\u4f4d\u7f6e\u53ef\u4ee5\u8df3\u8dc3\u7684\u6700\u5927\u957f\u5ea6\u3002<\/p>\n\n\n\n<p>\u4f60\u7684\u76ee\u6807\u662f\u4f7f\u7528\u6700\u5c11\u7684\u8df3\u8dc3\u6b21\u6570\u5230\u8fbe\u6570\u7ec4\u7684\u6700\u540e\u4e00\u4e2a\u4f4d\u7f6e\u3002<\/p>\n\n\n\n<p>\u5047\u8bbe\u4f60\u603b\u662f\u53ef\u4ee5\u5230\u8fbe\u6570\u7ec4\u7684\u6700\u540e\u4e00\u4e2a\u4f4d\u7f6e\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 1:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\u8f93\u5165:<\/strong> nums = &#91;2,3,1,1,4]\n<strong>\u8f93\u51fa:<\/strong> 2\n<strong>\u89e3\u91ca:<\/strong> \u8df3\u5230\u6700\u540e\u4e00\u4e2a\u4f4d\u7f6e\u7684\u6700\u5c0f\u8df3\u8dc3\u6570\u662f 2\u3002\n&nbsp;    \u4ece\u4e0b\u6807\u4e3a 0 \u8df3\u5230\u4e0b\u6807\u4e3a 1 \u7684\u4f4d\u7f6e\uff0c\u8df3&nbsp;1&nbsp;\u6b65\uff0c\u7136\u540e\u8df3&nbsp;3&nbsp;\u6b65\u5230\u8fbe\u6570\u7ec4\u7684\u6700\u540e\u4e00\u4e2a\u4f4d\u7f6e\u3002<\/code><\/pre>\n\n\n\n<p><strong>\u793a\u4f8b 2:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\u8f93\u5165:<\/strong> nums = &#91;2,3,0,1,4]\n<strong>\u8f93\u51fa:<\/strong> 2<\/code><\/pre>\n\n\n\n<p><strong>\u63d0\u793a:<\/strong><\/p>\n\n\n\n<ul><li><code>1 &lt;= nums.length &lt;= 10<sup>4<\/sup><\/code><\/li><li><code>0 &lt;= nums[i] &lt;= 1000<\/code><\/li><\/ul>\n\n\n\n<p>\u601d\u8def\uff1a\u8d2a\u5fc3\u7b97\u6cd5\uff1a<\/p>\n\n\n\n<p>\u5982\u679c\u6211\u4eec\u300c\u8d2a\u5fc3\u300d\u5730\u8fdb\u884c\u6b63\u5411\u67e5\u627e\uff0c\u6bcf\u6b21\u627e\u5230\u53ef\u5230\u8fbe\u7684\u6700\u8fdc\u4f4d\u7f6e\uff0c\u5c31\u53ef\u4ee5\u5728\u7ebf\u6027\u65f6\u95f4\u5185\u5f97\u5230\u6700\u5c11\u7684\u8df3\u8dc3\u6b21\u6570\u3002<\/p>\n\n\n\n<p>\u4f8b\u5982\uff0c\u5bf9\u4e8e\u6570\u7ec4\u00a0<code>[2,3,1,2,4,2,3]<\/code>\uff0c\u521d\u59cb\u4f4d\u7f6e\u662f\u4e0b\u6807 0\uff0c\u4ece\u4e0b\u6807 0 \u51fa\u53d1\uff0c\u6700\u8fdc\u53ef\u5230\u8fbe\u4e0b\u6807 2\u3002\u4e0b\u6807 0 \u53ef\u5230\u8fbe\u7684\u4f4d\u7f6e\u4e2d\uff0c\u4e0b\u6807 1 \u7684\u503c\u662f 3\uff0c\u4ece\u4e0b\u6807 1 \u51fa\u53d1\u53ef\u4ee5\u8fbe\u5230\u66f4\u8fdc\u7684\u4f4d\u7f6e\uff0c\u56e0\u6b64\u7b2c\u4e00\u6b65\u5230\u8fbe\u4e0b\u6807 1\u3002\u4ece\u4e0b\u6807 1 \u51fa\u53d1\uff0c\u6700\u8fdc\u53ef\u5230\u8fbe\u4e0b\u6807 4\u3002\u4e0b\u6807 1 \u53ef\u5230\u8fbe\u7684\u4f4d\u7f6e\u4e2d\uff0c\u4e0b\u6807 4 \u7684\u503c\u662f 4 \uff0c\u4ece\u4e0b\u6807 4 \u51fa\u53d1\u53ef\u4ee5\u8fbe\u5230\u66f4\u8fdc\u7684\u4f4d\u7f6e\uff0c\u56e0\u6b64\u7b2c\u4e8c\u6b65\u5230\u8fbe\u4e0b\u6807 4\u3002<\/p>\n\n\n\n<p>\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Solution:\r\n    def jump(self, nums: List&#91;int]) -> int:\r\n        n = len(nums)\r\n        maxPos, end, step = 0, 0, 0\r\n        for i in range(n - 1):\r\n            if maxPos >= i:\r\n                maxPos = max(maxPos, i + nums&#91;i])\r\n                if i == end:\r\n                    end = maxPos\r\n                    step += 1\r\n        return step<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u7ed9\u4f60\u4e00\u4e2a\u975e\u8d1f\u6574\u6570\u6570\u7ec4&nbsp;nums&nbsp;\uff0c\u4f60\u6700\u521d\u4f4d\u4e8e\u6570\u7ec4\u7684\u7b2c\u4e00\u4e2a\u4f4d\u7f6e\u3002 \u6570\u7ec4\u4e2d\u7684\u6bcf\u4e2a\u5143\u7d20\u4ee3\u8868\u4f60\u5728\u8be5 &hellip; <a href=\"http:\/\/139.9.1.231\/index.php\/2022\/01\/21\/leetcodeday45\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">leetcodeday45 &#8211;\u8df3\u8dc3\u6e38\u620f<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[],"_links":{"self":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2211"}],"collection":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/comments?post=2211"}],"version-history":[{"count":1,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2211\/revisions"}],"predecessor-version":[{"id":2212,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2211\/revisions\/2212"}],"wp:attachment":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/media?parent=2211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/categories?post=2211"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/tags?post=2211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}