{"id":2266,"date":"2022-01-22T15:49:53","date_gmt":"2022-01-22T07:49:53","guid":{"rendered":"http:\/\/139.9.1.231\/?p=2266"},"modified":"2022-01-22T15:49:55","modified_gmt":"2022-01-22T07:49:55","slug":"leetcodeday55","status":"publish","type":"post","link":"http:\/\/139.9.1.231\/index.php\/2022\/01\/22\/leetcodeday55\/","title":{"rendered":"leetcodeday55&#8212;\u8df3\u8dc3\u6e38\u620f"},"content":{"rendered":"\n<p>\u7ed9\u5b9a\u4e00\u4e2a\u975e\u8d1f\u6574\u6570\u6570\u7ec4&nbsp;<code>nums<\/code>&nbsp;\uff0c\u4f60\u6700\u521d\u4f4d\u4e8e\u6570\u7ec4\u7684&nbsp;<strong>\u7b2c\u4e00\u4e2a\u4e0b\u6807<\/strong>&nbsp;\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>\u5224\u65ad\u4f60\u662f\u5426\u80fd\u591f\u5230\u8fbe\u6700\u540e\u4e00\u4e2a\u4e0b\u6807\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b&nbsp;1\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\u8f93\u5165\uff1a<\/strong>nums = &#91;2,3,1,1,4]\n<strong>\u8f93\u51fa\uff1a<\/strong>true\n<strong>\u89e3\u91ca\uff1a<\/strong>\u53ef\u4ee5\u5148\u8df3 1 \u6b65\uff0c\u4ece\u4e0b\u6807 0 \u5230\u8fbe\u4e0b\u6807 1, \u7136\u540e\u518d\u4ece\u4e0b\u6807 1 \u8df3 3 \u6b65\u5230\u8fbe\u6700\u540e\u4e00\u4e2a\u4e0b\u6807\u3002<\/code><\/pre>\n\n\n\n<p><strong>\u793a\u4f8b&nbsp;2\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\u8f93\u5165\uff1a<\/strong>nums = &#91;3,2,1,0,4]\n<strong>\u8f93\u51fa\uff1a<\/strong>false\n<strong>\u89e3\u91ca\uff1a<\/strong>\u65e0\u8bba\u600e\u6837\uff0c\u603b\u4f1a\u5230\u8fbe\u4e0b\u6807\u4e3a 3 \u7684\u4f4d\u7f6e\u3002\u4f46\u8be5\u4e0b\u6807\u7684\u6700\u5927\u8df3\u8dc3\u957f\u5ea6\u662f 0 \uff0c \u6240\u4ee5\u6c38\u8fdc\u4e0d\u53ef\u80fd\u5230\u8fbe\u6700\u540e\u4e00\u4e2a\u4e0b\u6807\u3002<\/code><\/pre>\n\n\n\n<p><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n\n\n\n<ul><li><code>1 &lt;= nums.length &lt;= 3 * 10<sup>4<\/sup><\/code><\/li><li><code>0 &lt;= nums[i] &lt;= 10<sup>5<\/sup><\/code><\/li><\/ul>\n\n\n\n<p>\u601d\u8def\uff1a\u770b\u662f\u5426nums\u4e2d\u7684\u5143\u7d20\u80fd\u5426\u7ecf\u8fc70.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># @lc app=leetcode.cn id=55 lang=python3\r\n#\r\n# &#91;55] \u8df3\u8dc3\u6e38\u620f\r\n#\r\n\r\n# @lc code=start\r\nclass Solution:\r\n    def canJump(self, nums: List&#91;int]) -> bool:\r\n        re=0\r\n        if nums==&#91;0]:\r\n            return True\r\n        if 0 not in nums:\r\n            return True\r\n        for i in range(len(nums)-1,-1,-1):\r\n            if nums&#91;i]==0:\r\n                j=0\r\n                re=0\r\n                while j&lt;i:\r\n                    if nums&#91;j]&lt;=(i-j) and i!=len(nums)-1:\r\n                       j=j+1\r\n                       continue\r\n                    elif  nums&#91;j]&lt;(i-j) and i==len(nums)-1:\r\n                       j=j+1\r\n                       continue\r\n                    else:\r\n                        re=1 # True\r\n                        break\r\n                if re==0:\r\n                    return False\r\n        if re == 1:\r\n            return True \r\n        else:return False    \r\n                #return False<\/code><\/pre>\n\n\n\n<div class=\"wp-block-image is-style-default\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-267.png\" alt=\"\" class=\"wp-image-2270\" width=\"463\" height=\"175\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-267.png 735w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-267-300x114.png 300w\" sizes=\"(max-width: 463px) 100vw, 463px\" \/><\/figure><\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7ed9\u5b9a\u4e00\u4e2a\u975e\u8d1f\u6574\u6570\u6570\u7ec4&nbsp;nums&nbsp;\uff0c\u4f60\u6700\u521d\u4f4d\u4e8e\u6570\u7ec4\u7684&nbsp;\u7b2c\u4e00\u4e2a\u4e0b\u6807&nbsp;\u3002 \u6570 &hellip; <a href=\"http:\/\/139.9.1.231\/index.php\/2022\/01\/22\/leetcodeday55\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">leetcodeday55&#8212;\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\/2266"}],"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=2266"}],"version-history":[{"count":4,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2266\/revisions"}],"predecessor-version":[{"id":2271,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2266\/revisions\/2271"}],"wp:attachment":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/media?parent=2266"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/categories?post=2266"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/tags?post=2266"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}