lengths[i] is the longest forward jump allowed from cell i. From cell i you may land on any cell from i + 1 to i + lengths[i] (if lengths[i] = 0, you are stuck there).
You start on cell 0. Return True if you can reach the last cell and False otherwise.lengths=[1, 3, 0, 0, 2] → True
Jump from cell 0 to cell 1, then 3 forward straight to the last cell, 4.
lengths=[2, 1, 0, 3] → False
Cells 0, 1 and 2 cannot get past cell 2, and its jump length is zero.
lengths=[0] → True
We are already standing on the last cell.
len(lengths) ≤ 10⁵lengths[i] ≤ 10⁵lengths=[1, 3, 0, 0, 2]
True
Run checks the first 3 tests in your browser. Submit checks all 69 tests on the server, hidden ones included.