InferenceAI

Enter at least two characters to search.

Start free

Reach the End

mediumGreedy & Intervals25 min25 XP

You start at index 0. From index ii you may jump forward up to nums[i] positions. Return True if you can reach the last index.

Examples

EXAMPLE WALKTHROUGHreachable

A guided view of the published example, not a trace of your code.

INPUT[[2,3,1,1,4]]
TASKreach_the_end()
EXPECTED OUTPUTtrue

Start with the input values shown in this example.

Example 1 of 3

Input: nums = [2,3,1,1,4]

Output: true

Explanation: reachable

Input: nums = [3,2,1,0,4]

Output: false

Explanation: stuck at zero

Input: nums = [0]

Output: true

Explanation: already at the end

Hint 1

Track the furthest index reachable so far; if you ever stand beyond it, you are stuck.

Topics

DSAGreedy & IntervalsPython