A bug starts at position x.
The bug can move according to the following rules:
It can jump forward by a positions (moving to position curr + a).
It can jump backward by b positions (moving to position curr - b).
It cannot jump backward twice consecutively.
It cannot land on any position present in the array forbidden.
It cannot jump to any negative positions.
Return the minimum number of jumps required for the bug to reach position x. If it is impossible to reach position x, return
Constraints:
forbidden.length
a, b, forbidden[i]
x
All elements in forbidden are distinct.
Position x is not forbidden.
A bug starts at position x.
The bug can move according to the following rules:
It can jump forward by a positions (moving to position curr + a).
It can jump backward by b positions (moving to position curr - b).
It cannot jump backward twice consecutively.
It cannot land on any position present in the array forbidden.
It cannot jump to any negative positions.
Return the minimum number of jumps required for the bug to reach position x. If it is impossible to reach position x, return
Constraints:
forbidden.length
a, b, forbidden[i]
x
All elements in forbidden are distinct.
Position x is not forbidden.