| 26 | |
| 27 | """ |
| 28 | class Solution(object): |
| 29 | def jump(self, nums): |
| 30 | """ |
| 31 | :type nums: List[int] |
| 32 | :rtype: int |
| 33 | """ |
| 34 | if len(nums) == 1: |
| 35 | return 0 |
| 36 | |
| 37 | # dp = [nums[0]] |
| 38 | maxes = nums[0] |
| 39 | count = 1 |
| 40 | current_index = 0 |
| 41 | length = len(nums) - 1 |
| 42 | while 1: |
| 43 | if current_index + maxes >= length: |
| 44 | return count |
| 45 | base = 0 |
| 46 | index = current_index |
| 47 | for i in xrange(current_index, current_index+maxes+1): |
| 48 | if nums[i] + i > base: |
| 49 | base = nums[i] + i |
| 50 | index = i |
| 51 | |
| 52 | current_index = index |
| 53 | maxes = base-index |
| 54 | count += 1 |
nothing calls this directly
no outgoing calls
no test coverage detected