LeetCode657.判断路线成圈

class Solution:
    def judgeCircle(self, moves):
        """
        :type moves: str
        :rtype: bool
        """
        count_R = 0
        count_U = 0
        for act in moves :
            if act == 'R':
                count_R = count_R + 1
            elif act == 'L' :
                count_R = count_R - 1
            elif act == 'U' :
                count_U = count_U + 1
            elif act == 'D' :
                count_U = count_U - 1
            else :
                pass
        if count_U == 0 and count_R == 0 :
            return True
        else :
            return False

posted @ 2018-05-03 20:23  kkkkkksssss  阅读(90)  评论(0编辑  收藏  举报