2
3
1
1
4
[0][1][2][3][4]
Greedy · farthest reach in one pass
▸1given nums2farthest ← 03for i ← 0 to n − 1:4 if i > farthest: return false5 farthest = max(farthest, i + nums[i])6 if farthest ≥ n − 1: return true7return true
state
- n5
- last4
- nums[2, 3, 1, 1, 4]