Dynamic programming 1D: Count ways to move from step 0 to step n using jumps of 1 or 2, without landing on any blocked step.
Input: A JSON object { "n": number, "blocked": number[] }.
Output: A JSON integer number of valid jump sequences.
Constraints:
- 0 <= n <= 100000
- blocked contains positions in 0..n
- If step 0 or step n is blocked, the answer is 0
Read one JSON value from stdin and print exactly one JSON-serialized answer to stdout with no extra text.
Difficulty: HARD. Variant: 24. Favor a pragmatic solution that is easy to ship, read, and adapt.
Practice context
This coding (algo) exercise trains prompt interpretation, explicit assumptions, a concrete response, and a concise explanation of the decisions made. It is marked hard difficulty.
The signed-in workspace provides the tools required by the round, such as recording, code execution, diagrams, structured notes, or