Can you reach the end?

A free medium coding practice problem. Solve it in JavaScript, TypeScript or Python and check your solution against fresh hidden tests — edge cases and random inputs — as often as you like.

Difficulty
Medium
Type
Function
Languages
JavaScript, TypeScript or Python

Problem

You start at index 0 of jumps; from index i you may move forward by any distance from 1 to jumps[i]. Return true if you can reach the last index. Inputs can have 100,000 elements.

Function signature

// JavaScript
function canReachEnd(jumps)

// TypeScript
function canReachEnd(jumps: any): any

// Python
def can_reach_end(jumps):

Examples

  1. canReachEnd([2,3,1,1,4]) → true
  2. canReachEnd([3,2,1,0,4]) → false

How checking works

Run your code against the examples above, then submit a check: it runs on the server against hidden tests built fresh each time, including edge cases and random inputs. Practice is untimed and never affects a verified score; when you are ready, take a graded coding challenge to earn a badge.

More practice problems

Next steps