Skip to content

Latest commit

 

History

History
28 lines (24 loc) · 609 Bytes

File metadata and controls

28 lines (24 loc) · 609 Bytes

Lamarck      

3248 矩阵中的蛇


01 随便写写

class Solution(object):
    def finalPositionOfSnake(self, n, commands):
        """
        :type n: int
        :type commands: List[str]
        :rtype: int
        """
        ans = 0
        for command in commands:
            if command == "UP":
                ans -= n
            elif command == "DOWN":
                ans += n
            elif command == "RIGHT":
                ans += 1
            elif command == "LEFT":
                ans -= 1
        return ans