<p>You are given an integer array <code>nums</code>. You are initially positioned at the array&#39;s <strong>first index</strong>, and each element in the array represents your maximum jump length at that position.</p>

<p>Return <code>true</code><em> if you can reach the last index, or </em><code>false</code><em> otherwise</em>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> nums = [2,3,1,1,4]
<strong>Output:</strong> true
<strong>Explanation:</strong> Jump 1 step from index 0 to 1, then 3 steps to the last index.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> nums = [3,2,1,0,4]
<strong>Output:</strong> false
<strong>Explanation:</strong> You will always arrive at index 3 no matter what. Its maximum jump length is 0, which makes it impossible to reach the last index.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= nums.length &lt;= 10<sup>4</sup></code></li>
	<li><code>0 &lt;= nums[i] &lt;= 10<sup>5</sup></code></li>
</ul>

class Solution:
    def canJump(self, nums: List[int]) -> bool:
        #if nums[0]==0 and len(nums)==1:
        #    return True
        #if nums[0]==0 and len(nums)!=1:
        #    return False
        #zeros={}
        #k=-1
        #for i in range(len(nums)):
        #    print('hello')
        #    if nums[i]==0 and nums[i-1]!=0:
        #        k=i-1
        #        zeros[nums[k]]=1
        #    if nums[i]==0 and nums[i-1]==0:
        #        zeros[nums[k]]+=1
        #if not zeros : 
        #    return True 
        #print(zeros)
        #sol=[i for i in zeros if zeros[i]>=i]
        #print(sol)
        #return(not sol)
        
        
        #if prod(nums)>0:
        #    return True
        #if nums[0]==0 and len(nums)==1:
        #    return True
        #if nums[0]==0 and len(nums)!=1:
        #    return False
        #k=nums[0]
        #i=0
        #while i<len(nums)-1:
        #    i+=1
        #    if nums[i]!=0 :
        #        k=nums[i]
        #    else :
        #        k-=1
        #    if nums[i]>=len(nums)-1-i:
        #        print('yallah')
        #        return True
        #    print(f'i:{i} nums:{nums[i]} k:{k}') 
        #    if k==0 and i<len(nums)-1:
        #        print('hala')
        #        return False
        #return True    
                
                
        #        k=nums[i]
        #    print(f'i:{i} nums:{nums[i]} k:{k}')
        #    if nums[i]==0 and nums[i-1]!=0:
        #        k=nums[i-1]
        #        k-=1
        #    if nums[i]==0 and nums[i-1]==0:
        #        k-=1
        #    if k<0: return False
        #return not k<0
        
        gas = 0
        for n in nums:
            if gas < 0:
                return False
            elif n > gas:
                gas = n
            gas -= 1
            
        return True
                
            
17500