Just found out why I kept failing at the last test case

  • 0

    Suppose we have the following state:

    | S | T |

    | S | H |

    S is the body of the snake, H is the head of the snake, and T is the tail of the snake.

    If I want to move the head to the Tail position (i.e. an 'U' move), it is a valid move ONLY IF there is NO food at the tail position.
    i.e. the snake doesn't remove its tail if it eats food

    Hope this could help anyone who is struggling on the last test case!

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.