Skip to content

Commit f99318d

Browse files
committed
Create README - LeetHub
1 parent 37ec6dd commit f99318d

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

robot-bounded-in-circle/README.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<h2>1041. Robot Bounded In Circle</h2><h3>Medium</h3><hr><div><p>On an infinite plane, a robot initially stands at <code>(0, 0)</code> and faces north. The robot can receive one of three instructions:</p>
2+
3+
<ul>
4+
<li><code>"G"</code>: go straight 1 unit;</li>
5+
<li><code>"L"</code>: turn 90 degrees to the left;</li>
6+
<li><code>"R"</code>: turn 90 degrees to the right.</li>
7+
</ul>
8+
9+
<p>The robot performs the <code>instructions</code> given in order, and repeats them forever.</p>
10+
11+
<p>Return <code>true</code> if and only if there exists a circle in the plane such that the robot never leaves the circle.</p>
12+
13+
<p>&nbsp;</p>
14+
<p><strong>Example 1:</strong></p>
15+
16+
<pre><strong>Input:</strong> instructions = "GGLLGG"
17+
<strong>Output:</strong> true
18+
<strong>Explanation:</strong> The robot moves from (0,0) to (0,2), turns 180 degrees, and then returns to (0,0).
19+
When repeating these instructions, the robot remains in the circle of radius 2 centered at the origin.</pre>
20+
21+
<p><strong>Example 2:</strong></p>
22+
23+
<pre><strong>Input:</strong> instructions = "GG"
24+
<strong>Output:</strong> false
25+
<strong>Explanation:</strong> The robot moves north indefinitely.</pre>
26+
27+
<p><strong>Example 3:</strong></p>
28+
29+
<pre><strong>Input:</strong> instructions = "GL"
30+
<strong>Output:</strong> true
31+
<strong>Explanation:</strong> The robot moves from (0, 0) -&gt; (0, 1) -&gt; (-1, 1) -&gt; (-1, 0) -&gt; (0, 0) -&gt; ...</pre>
32+
33+
<p>&nbsp;</p>
34+
<p><strong>Constraints:</strong></p>
35+
36+
<ul>
37+
<li><code>1 &lt;= instructions.length &lt;= 100</code></li>
38+
<li><code>instructions[i]</code> is <code>'G'</code>, <code>'L'</code> or, <code>'R'</code>.</li>
39+
</ul>
40+
</div>

0 commit comments

Comments
 (0)