Company: Accolite_9oct
Difficulty: medium
Ant's Journey Home Problem Description Andy the ant lives on a straight forest path that is modelled as the x-axis. His anthill is at position x . At dusk Andy is at position 0 and wants to get home. Andy moves only in jumps, and each jump is one of two kinds: Forward: move from position p to position p + a . Backward: move from position p to position p - b . His journey must follow these rules: Andy cannot make two backward jumps in a row. After a backward jump, his next jump (if any) must be a forward jump. Some positions are marked with red flags and are listed in the array prohibited . Andy must never land on a prohibited position. Andy can never land on a negative position. Landing on position 0 itself is allowed. Andy may march past his home (to positions greater than x ) if that helps him come back to x later. There is no upper limit on the positions he may visit. You are given the array prohibited and an array data of size 3 that holds a , b and x , in that order. Return the le