python complex number solution


  • 0
    Z
    class Solution(object):
        def judgeCircle(self, moves):
            original = 0
            directions = {'U': 1j, 'D': -1j, 'L': -1, 'R': 1}
            for move in moves:
                original += directions[move]
            return original == 0

Log in to reply
 

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