Python3 Solution


  • 0
    M
        x_cor = 0
        y_cor = 0
        dirs = {'U': 1, 'D':-1, 'L':-1,'R':1}
        for i in moves:
            if i == 'U' or i == 'D':
                y_cor += dirs[i]
            else:
                x_cor += dirs[i]
        return x_cor == 0 and y_cor == 0

Log in to reply
 

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