DSA · Greedy · #94
Jump Game
Module 51 · difficulty 3/5·⏱ 30:00starts on first keystroke
You are given an integer array `nums`. You start at the first index `0`, and each element `nums[i]` represents your **maximum** jump length from that position. Implement `canJump(nums)` that returns `true` if you can reach the last index, and `false` otherwise.
Examples
nums = [2,3,1,1,4]→true— Jump 1 step from index 0 to 1, then 3 steps to the last index.nums = [3,2,1,0,4]→false— You will always arrive at index 3 with max jump 0, so you can never reach the last index.nums = [0]→true— Already at the last index without moving.
Constraints
- · 1 <= nums.length <= 10^4
- · 0 <= nums[i] <= 10^5
Session phases
A · Clarify
B · Approach
C · Complexity
D · Edges
E · Code
F · Tradeoff
G · Score
Phase A — Clarify
Ask questions about input bounds, types, and edge constraints.
Ask the coach clarifying questions about the problem.
When you've covered this phase, advance to the next.