Question: ( Solve in Javascript Please ) You are given an input string that controls the movement of a robot, F means take a
Solve in Javascript Please You are given an input string that controls the movement of a robot, F means take a step forward, L means turn degrees to the left and
R means turn degrees to the right. EgFLF moves the robot one step forward, then turns it left by degrees, then moves the robot one step forward. Write a function that returns the minimum number of commands that the robot needs to return to its starting
point after following all the input commands. You should ignore any characters that are not capital F L or R Hint: you may wish to track the robots position using XY coordinates, assuming it starts at
For example:
RF returns robot must turn twice and move forward one step egRRF
LFRFRFR returns robot must step forward to return
FxLxLxFx returns robot is already back at its starting point
execution time limit seconds js
memory limit GB
input string directionsThe directions for the robot
output integer
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
