Walking Robot Simulation II — LeetCode 2069 Python Solution

MediumDesignSimulation
Problem
#2069
Reading time
2 min

The problem

A width x height grid is on an XY-plane with the bottom-left cell at (0, 0) and the top-right cell at (width - 1, height - 1). The grid is aligned with the four cardinal directions ("North", "East", "South", and "West").

Example

Input
["Robot", "step", "step", "getPos", "getDir", "step", "step", "step", "getPos", "getDir"]
Output
[null, null, null, [4, 0], "East", null, null, null, [1, 2], "West"]
Explanation
Robot robot = new Robot(6, 3); // Initialize the grid and the robot at (0, 0) facing East.

Complexity

MeasureComplexity
TimeVaries by operation
SpaceVaries by operation auxiliary

Related problems

Frequently asked questions

How hard is LeetCode 2069. Walking Robot Simulation II?
LeetCode 2069. Walking Robot Simulation II is rated Medium on LeetCode.
What is the time complexity of LeetCode 2069. Walking Robot Simulation II?
The Python solution on this page runs in Varies by operation.
What is the space complexity of LeetCode 2069. Walking Robot Simulation II?
The Python solution on this page uses Varies by operation auxiliary space.
What topics does LeetCode 2069. Walking Robot Simulation II cover?
LeetCode 2069. Walking Robot Simulation II is tagged Design and Simulation on LeetCode.

Stuck on problems like this in a live interview?

Stealth Interview is a desktop app for macOS and Windows. It reads the problem off your screen and returns a working solution with a step-by-step explanation and its time and space complexity — invisible to screen sharing.

Get Stealth Interview