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

原文地址:https://www.cnblogs.com/accumulationbystep/p/10448572.html