{
  "type": "code_options",
  "author": "https://github.com/qiyuangong/leetcode",
  "source": "solution.md",
  "exercise_id": "84136d3c63b047249adb53ffcfd69532",
  "keywords": "贪心,数组,动态规划",
  "title": "跳跃游戏 II",
  "desc": [
    {
      "content": "\n<p>给定一个非负整数数组，你最初位于数组的第一个位置。</p>\n<p>数组中的每个元素代表你在该位置可以跳跃的最大长度。</p>\n<p>你的目标是使用最少的跳跃次数到达数组的最后一个位置。</p>\n<p><strong>示例:</strong></p>\n<pre><strong>输入:</strong> [2,3,1,1,4]<strong><br />输出:</strong> 2<strong><br />解释:</strong> 跳到最后一个位置的最小跳跃数是 2。从下标为 0 跳到下标为 1 的位置，跳&nbsp;1&nbsp;步，然后跳&nbsp;3&nbsp;步到达数组的最后一个位置。</pre>\n<p><strong>说明:</strong></p>\n<p>假设你总是可以到达数组的最后一个位置。</p>",
      "language": "markdown"
    }
  ],
  "answer": [
    {
      "content": "",
      "language": "python"
    }
  ],
  "prepared": [
    [
      {
        "content": "",
        "language": "python"
      }
    ],
    [
      {
        "content": "",
        "language": "python"
      }
    ],
    [
      {
        "content": "",
        "language": "python"
      }
    ]
  ],
  "template": {
    "content": "class Solution:\n\tdef jump(self, nums):\n\t\tif len(nums) <= 1:\n\t\t\treturn 0\n\t\tend = 0 + nums[0]\n\t\tstart = 0\n\t\tstep = 1\n\t\tmaxDis = 0 + nums[0]\n\t\twhile end < len(nums) - 1:\n\t\t\tfor i in range(start + 1, end + 1):\n\t\t\t\tmaxDis = max(maxDis, nums[i] + i)\n\t\t\tstart = end\n\t\t\tend = maxDis\n\t\t\tstep += 1\n\t\treturn step\n# %%\ns = Solution()\nprint(s.jump(nums = [2,3,0,1,4]))",
    "language": "python"
  },
  "node_id": "dailycode-bc3eb1c20a03474e83551d80ab9725c7",
  "license": "csdn.net",
  "created_at": 1637894159,
  "topic_link": "https://bbs.csdn.net/topics/600469921"
}