4 LINE PYTHON SOLUTION


  • 0
    M

    U is opposite of D and L is opposite of R. As long as U cancels out D and L cancels out R then position remains 0.
    '''
    class Solution:
    def judgeCircle(self, moves):
    """
    :type moves: str
    :rtype: bool
    """
    if moves.count('L') == moves.count('R') and moves.count('U') == moves.count('D'):
    return True
    else:
    return False
    '''


Log in to reply
 

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