Greedy
148 / 170GreedyLesson 2 of 9About 39 min
You do not need to know how you got somewhere. Only how far anything can now take you.
This updates the running reach before checking whether the current position was reachable. The first input is not finishable and the second is. Type the two values it prints.
def can_finish_broken(jumps): furthest = 0 for position, jump in enumerate(jumps): furthest = max(furthest, position + jump) if position > furthest: return False return True print(can_finish_broken([3, 2, 1, 0, 4]), can_finish_broken([2, 3, 1, 1, 4]))Read the constraints first and let them tell you what complexity is expected. Derive the approach, implement it, run the tests, and submit when it passes.