As reported: Zoox coding interview (2025): path transformation — take a prefix of a movement command string, reverse it, apply a 180-degree shift, and add a fixed start marker.
A vehicle's path is a string input_path_flow of commands: F (move forward), L (turn left) and R (turn right). Given the path and an integer num_steps, build the path for driving back:
- Take the first
num_stepscommands. Ifnum_stepsis 0 this is empty; if it exceeds the path's length, take the whole path. - Reverse their order.
- Apply a 180-degree shift:
FstaysF,LbecomesR,RbecomesL. - Prefix the result with
A. The output always starts withA.
Implement process_path(input_path_flow, num_steps) -> str.
Examples
("FFFFFL", 6) -> "ARFFFFF" FFFFFL -> reversed LFFFFF -> shifted RFFFFF
("FFFLR", 4) -> "ARFFF" FFFL -> LFFF -> RFFF
("FLR", 0) -> "A"
Constraints: 0 ≤ len(input_path_flow) ≤ 10^5; every character is F, L or R; 0 ≤ num_steps ≤ 10^9.
Code runner format: one JSON value per line: input_path_flow, then num_steps. Implement process_path (Python) / processPath (other languages); the harness prints the returned string.