Python solution using Counter


  • 0
    Y

    from collections import Counter

    class Solution(object):
    def judgeCircle(self, moves):
    """
    :type moves: str
    :rtype: bool
    """
    c = Counter(moves)
    return (c['U'] == c['D']) and (c['L'] == c['R'])


Log in to reply
 

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