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
原文地址:https://www.cnblogs.com/seenthewind/p/10523654.html