Tap here to switch tabs
Problem
Submissions

Problem: Robot Return to Origin

med
30 min
Try to solve the Robot Return to Origin problem.

Statement

A robot starts at the origin on a 2D plane and receives a sequence of moves in moves.

Each character in moves represents one move:
'U' moves the robot up, 'D' moves it down, 'L' moves it left, and 'R' moves it right.

Return true if the robot returns to the origin after completing all moves. Otherwise, return false.

Note: The robot starts at the origin.

Constraints:

  • 1<=1 <= moves.length <=2∗104<= 2 * 10^4

  • moves only contains the characters 'U', 'D', 'L', and 'R'

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Robot Return to Origin

med
30 min
Try to solve the Robot Return to Origin problem.

Statement

A robot starts at the origin on a 2D plane and receives a sequence of moves in moves.

Each character in moves represents one move:
'U' moves the robot up, 'D' moves it down, 'L' moves it left, and 'R' moves it right.

Return true if the robot returns to the origin after completing all moves. Otherwise, return false.

Note: The robot starts at the origin.

Constraints:

  • 1<=1 <= moves.length <=2∗104<= 2 * 10^4

  • moves only contains the characters 'U', 'D', 'L', and 'R'