mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-05 15:31:43 +08:00
存量题库数据更新
This commit is contained in:
@@ -19,26 +19,26 @@
|
||||
</ul>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Example 1:</strong></p>
|
||||
<p><strong class="example">Example 1:</strong></p>
|
||||
<img alt="example-1" src="https://assets.leetcode.com/uploads/2021/10/09/example-1.png" style="width: 498px; height: 268px;" />
|
||||
<pre>
|
||||
<strong>Input</strong>
|
||||
["Robot", "move", "move", "getPos", "getDir", "move", "move", "move", "getPos", "getDir"]
|
||||
["Robot", "step", "step", "getPos", "getDir", "step", "step", "step", "getPos", "getDir"]
|
||||
[[6, 3], [2], [2], [], [], [2], [1], [4], [], []]
|
||||
<strong>Output</strong>
|
||||
[null, null, null, [4, 0], "East", null, null, null, [1, 2], "West"]
|
||||
|
||||
<strong>Explanation</strong>
|
||||
Robot robot = new Robot(6, 3); // Initialize the grid and the robot at (0, 0) facing East.
|
||||
robot.move(2); // It moves two steps East to (2, 0), and faces East.
|
||||
robot.move(2); // It moves two steps East to (4, 0), and faces East.
|
||||
robot.step(2); // It moves two steps East to (2, 0), and faces East.
|
||||
robot.step(2); // It moves two steps East to (4, 0), and faces East.
|
||||
robot.getPos(); // return [4, 0]
|
||||
robot.getDir(); // return "East"
|
||||
robot.move(2); // It moves one step East to (5, 0), and faces East.
|
||||
robot.step(2); // It moves one step East to (5, 0), and faces East.
|
||||
// Moving the next step East would be out of bounds, so it turns and faces North.
|
||||
// Then, it moves one step North to (5, 1), and faces North.
|
||||
robot.move(1); // It moves one step North to (5, 2), and faces <strong>North</strong> (not West).
|
||||
robot.move(4); // Moving the next step North would be out of bounds, so it turns and faces West.
|
||||
robot.step(1); // It moves one step North to (5, 2), and faces <strong>North</strong> (not West).
|
||||
robot.step(4); // Moving the next step North would be out of bounds, so it turns and faces West.
|
||||
// Then, it moves four steps West to (1, 2), and faces West.
|
||||
robot.getPos(); // return [1, 2]
|
||||
robot.getDir(); // return "West"
|
||||
|
Reference in New Issue
Block a user