Jump Game II LeetCode solution in Python
1# Runtime: 305 ms (Top 40.77%) | Memory: 15 MB (Top 90.04%)2class Solution(object):3def jump(self, nums):4ans = l = r = 056while r < len(nums) - 1:7farthestJump = 089for i in range(l, r + 1):10farthestJump = max(farthestJump, i + nums[i])1112l = r + 113r = farthestJump14ans += 11516return ans