0
to the queue with 0
jumps and mark it as not having a backward jump.x
, return the jump count as the result.
c. Calculate the next forward and backward positions.
d. If the forward position is not forbidden, not visited, and within the maximum boundary, enqueue it and mark it as visited.
e. If the backward position is not forbidden, not visited, not negative, and the last jump was not backward, enqueue it and mark it as visited.x
, return -1
to indicate the home cannot be reached.