solution


  • 0
    A
    class Solution:
        def __init__(self, nums):
            self.nums = nums
            self.count = 0
            self.last = len(nums) - 1
            self.current = [0]
            
        def jump(self):
            while (max(self.current) < self.last):
                self.jumpNext()
                
        def jumpNext(self):
            self.count = self.count + 1
            new_current = []
            for i in self.current:
                mStep = self.nums[i]
                tmp = [i + x for x in range(1, mStep+1)]
                new_current = new_current + tmp
                
            self.current = new_current
            
    
    s = Solution([2,3,1,1,4])
    s.jump()
    print(s.count)
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.