NewProject Coding is here — build features and fix bugs in real codebases with an AI assistantSee what's new

A bootloader stores its program as an array of text instructions, and you need to find where the execution first starts repeating.

You are given instructions, where each entry has the form "<operation> <value>". The operation is one of "plus", "next", or "jump".

  • "plus x" adds x to a global accumulator, then moves to the next instruction.
  • next x leaves the accumulator unchanged and moves to the next instruction. The value x is preserved in the instruction format but is ignored and not used in this question.
  • "jump x" leaves the accumulator unchanged, then moves to the instruction at the current index plus x.
Test Cases
Input
Output
Expected