#330 Checking Whether the Manipulator Returns to the Starting Point
A manipulator starts at its initial point and can move:
- forward
- backward
- right
- left
The manipulator receives a random string containing one-character command tokens. It processes the tokens sequentially and executes the corresponding commands. After processing all tokens, the manipulator stops.
The manipulator supports four token types: U, D, R, and L, corresponding to movement directions.
The tokens are not separated inside the string.
Write a function that accepts a token string and determines whether the manipulator is at its starting point after stopping:
UURLLLRUDDRD...
Question review
Sign in to start the dialogue
The mentor keeps the context of the current question and your previous messages.
Sign in
Available with Premium
This is just one of the solutions available with Premium. And more:
- 250+ advanced lectures
- 1300+ practice exercises
- 500+ solutions to problems from real interviews
- Personalized Java Hub certificates
- Expanded access to the AI mentor