Jane Street
1 DSA problems asked in Jane Street coding interviews
1 problem
Arrays & Hashing1
Walking Robot Simulation
A robot on an infinite XY-plane starts at `(0, 0)` facing north. It receives a sequence of commands `moves` (LeetCode calls this parameter `commands`): - `-2`: turn left 90 degrees. - `-1`: turn right 90 degrees. - `1 <= k <= 9`: move forward `k` units, one unit at a time. Some grid squares are obstacles; the `i`-th one is at `obstacles[i] = (x_i, y_i)`. If the robot would step onto an obstacle, it stays where it is and moves on to the next command. Return *the **maximum squared Euclidean distance** from the origin that the robot ever reaches* (for example, if the distance is 5, return 25). **Note:** north is +Y, east is +X, south is -Y, west is -X. An obstacle may sit at the origin; the robot ignores it until it moves off, and cannot return there afterwards.