There is an
A snake starts at cell commands that describes the movement of the snake at each step:
"UP": moves one cell up to
"DOWN": moves one cell down to
"LEFT": moves one cell left to
"RIGHT": moves one cell right to
Return the value of the cell where the snake ends up after executing all the given commands.
Constraints:
n
commands.length
commands consists only of "UP", "RIGHT", "DOWN", and "LEFT".
The input is generated such that the snake will not move outside of the boundaries.
There is an
A snake starts at cell commands that describes the movement of the snake at each step:
"UP": moves one cell up to
"DOWN": moves one cell down to
"LEFT": moves one cell left to
"RIGHT": moves one cell right to
Return the value of the cell where the snake ends up after executing all the given commands.
Constraints:
n
commands.length
commands consists only of "UP", "RIGHT", "DOWN", and "LEFT".
The input is generated such that the snake will not move outside of the boundaries.