{
  "type": "code_options",
  "author": "https://github.com/qiyuangong/leetcode",
  "source": "solution.md",
  "exercise_id": "2a0c9ca788f9488d8bd946dc1a1e3795",
  "keywords": "贪心,数组,动态规划",
  "title": "跳跃游戏",
  "desc": [
    {
      "content": "\n<p>给定一个非负整数数组 <code>nums</code> ，你最初位于数组的 <strong>第一个下标</strong> 。</p><p>数组中的每个元素代表你在该位置可以跳跃的最大长度。</p><p>判断你是否能够到达最后一个下标。</p><p> </p><p><strong>示例 1：</strong></p><pre><strong>输入：</strong>nums = [2,3,1,1,4]<strong><br />输出：</strong>true<strong><br />解释：</strong>可以先跳 1 步，从下标 0 到达下标 1, 然后再从下标 1 跳 3 步到达最后一个下标。</pre><p><strong>示例 2：</strong></p><pre><strong>输入：</strong>nums = [3,2,1,0,4]<strong><br />输出：</strong>false<strong><br />解释：</strong>无论怎样，总会到达下标为 3 的位置。但该下标的最大跳跃长度是 0 ， 所以永远不可能到达最后一个下标。</pre><p> </p><p><strong>提示：</strong></p><ul>\t<li><code>1 <= nums.length <= 3 * 10<sup>4</sup></code></li>\t<li><code>0 <= nums[i] <= 10<sup>5</sup></code></li></ul>",
      "language": "markdown"
    }
  ],
  "answer": [
    {
      "content": "",
      "language": "python"
    }
  ],
  "prepared": [
    [
      {
        "content": "",
        "language": "python"
      }
    ],
    [
      {
        "content": "",
        "language": "python"
      }
    ],
    [
      {
        "content": "",
        "language": "python"
      }
    ]
  ],
  "template": {
    "content": "class Solution(object):\n\tdef canJump(self, nums):\n\t\t\"\"\"\n\t\t:type nums: List[int]\n\t\t:rtype: bool\n\t\t\"\"\"\n\t\tlength = len(nums)\n\t\tbegin = length - 1\n\t\tfor i in reversed(range(length - 1)):\n\t\t\tif i + nums[i] >= begin:\n\t\t\t\tbegin = i\n\t\treturn not begin\n# %%\ns = Solution()\nprint(s.canJump(nums = [2,3,1,1,4]))",
    "language": "python"
  },
  "node_id": "dailycode-a8944f7f59b943228d64d83b7428caa0",
  "license": "csdn.net",
  "created_at": 1637894159,
  "topic_link": "https://bbs.csdn.net/topics/600470122"
}