657. Robot Return to Origin

class Solution:
    def judgeCircle(self, moves: str) -> bool:
        u,d,l,r = 0,0,0,0
        for move in moves:
            if move is 'U':
                u += 1
            elif move is 'D':
                d += 1
            elif move is 'L':
                l += 1
            elif move is 'R':
                r += 1
        if u!=d or l!=r:
            return False
        return True

  76ms,13.1M

posted @ 2019-02-28 10:11  bluedream1000  阅读(140)  评论(0编辑  收藏  举报