A simple solution with Python3


  • 0
    G
    class Solution:
        def judgeCircle(self, moves):
            """
            :type moves: str
            :rtype: bool
            """
            U = moves.count('U')
            D = moves.count('D')
            L = moves.count('L')
            R = moves.count('R')
            return True if U == D and L == R else False
    

    As you see, it is a really simple answer.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.