Instacart Phone Screen

Anonymous User
2600
Aug 02, 2021

Giving back to the community.

Question: Transform from start to end and return its shortest path.

Start = [L,_,_,R,_,R]
End = [_,R,R,L,_,_]

Return its path

[_,L,_,R,_R]
[_,_,L,R,_R]
[_,R,L,_,_R]
[_,R,_,L,_R]
[_,R,_,L,R_]
[_,R,R,L,_,_]

Rules:

  1. L can only move to the right
  2. R can only move to the left
  3. When L and R are next to one another, they can jump over. ie: _, L, R, _ => R, L, _, _, or _, _, R, L
  4. Jumping more than 2 units is not allowed. ie: ,L,L,R,, cannot become R,L,L, _ ,_

Good luck!

Comments (1)