Algorithmic patterns · 15 / 15 Exercise Hard

Jump game

Objective

Each number is the maximum jump that can be made from that position. A greedy strategy keeps the farthest reachable position at every moment and checks whether the end is reached.

Instructions

  • Read a line of non-negative integers; you start at the first position.
  • Show Reachable if the last position can be reached or Not reachable if not.
Input
2 3 1 1 4
Output
Reachable

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise