mirror of
https://github.com/devenperez/leetcode.git
synced 2026-06-13 14:57:08 +00:00
12 lines
384 B
Python
12 lines
384 B
Python
class Solution:
|
|
def finalPositionOfSnake(self, n: int, commands: List[str]) -> int:
|
|
movesCount = {
|
|
"RIGHT": 0,
|
|
"LEFT": 0,
|
|
"UP": 0,
|
|
"DOWN": 0,
|
|
}
|
|
for command in commands:
|
|
movesCount[command] += 1
|
|
|
|
return movesCount["RIGHT"] - movesCount["LEFT"] + n * (movesCount["DOWN"] - movesCount["UP"]) |