2019年3月13日 657. Robot Return to Origin

水一题弱题庆祝IBM MQ搭建成功。

class Solution(object):
    def judgeCircle(self, moves):
        """
        :type moves: str
        :rtype: bool
        """
        result = [0, 0]
        for i in moves:
            for k, v in (('R', (1, 0)),
                        ('L', (-1, 0)),
                        ('U', (0, 1)),
                        ('D', (0, -1))):
                if i == k:
                    result[0] += v[0]
                    result[1] += v[1]

        return result[0] == 0 and result[1] == 0
posted @ 2019-03-13 15:48  miuc  阅读(150)  评论(0编辑  收藏  举报