Calculate the number of each completely opposite moves

  • 0

    Simple fundamental is to check if the robot moves in one direction once, does it goes opposite once too or not. If the count of steps in any one direction is not equal to the count in another direction then the robot doesn't makes a circle.
    Code for python 3:

            for i in moves:
                if i not in move:
            if move['U']==move['D'] and move['R']==move['L']:
                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.