You are given two arrays of length n: a string array instructions and an integer array values.
A simulation begins at index i:
If index i has already been visited or is out of bounds (meaning i i n), the process ends immediately.
If instructions[i] is equal to "add", add values[i] to the score and advance to index i
If instructions[i] is equal to "jump", move directly to index i values[i].
Return the total score accumulated when the process terminates.
Constraints:
n instructions.length values.length
n
instructions[i] is either "add" or "jump".
values[i]
You are given two arrays of length n: a string array instructions and an integer array values.
A simulation begins at index i:
If index i has already been visited or is out of bounds (meaning i i n), the process ends immediately.
If instructions[i] is equal to "add", add values[i] to the score and advance to index i
If instructions[i] is equal to "jump", move directly to index i values[i].
Return the total score accumulated when the process terminates.
Constraints:
n instructions.length values.length
n
instructions[i] is either "add" or "jump".
values[i]