hops and a starting cell start. Standing on cell i, you can hop exactly hops[i] cells to the left or exactly hops[i] cells to the right, landing on i - hops[i] or i + hops[i]. You may never hop outside the array.
Return True if, starting from start, you can land on some cell that holds 0, and False otherwise.hops=[3, 1, 2, 0, 4, 1], start=5 → True
The path is 5 → 4 → 0 → 3: from cell 5 hop 1 left, from 4 hop 4 left, from 0 hop 3 right, and cell 3 holds a zero.
hops=[1, 2, 0, 2, 1], start=3 → False
Cell 3 leads only to cell 1, and cell 1 leads only back to 3. The zero in cell 2 is out of reach.
hops=[0], start=0 → True
We are already standing on a zero.
len(hops) ≤ 5·10⁴hops[i] < len(hops)start < len(hops)hops=[3, 1, 2, 0, 4, 1], start=5
True
Run checks the first 3 tests in your browser. Submit checks all 112 tests on the server, hidden ones included.