Skip to content

Commit c50d339

Browse files
author
Shuo
authored
Merge pull request #521 from openset/develop
Update: description
2 parents f2c8614 + d6d96ef commit c50d339

File tree

4 files changed

+56
-11
lines changed

4 files changed

+56
-11
lines changed

problems/flower-planting-with-no-adjacent/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,12 @@
6060
</div>
6161
</div>
6262
</div>
63+
64+
### Related Topics
65+
[[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)]
66+
67+
### Hints
68+
<details>
69+
<summary>Hint 1</summary>
70+
Since each garden is connected to at most 3 gardens, there's always an available color for each garden. For example, if one garden is next to gardens with colors 1, 3, 4, then color #2 is available.
71+
</details>

problems/longest-duplicate-substring/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,17 @@ Next >
3939
<li><code>2 &lt;= S.length &lt;= 10^5</code></li>
4040
<li><code>S</code> consists of lowercase English letters.</li>
4141
</ol>
42+
43+
### Related Topics
44+
[[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)]
45+
[[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)]
46+
47+
### Hints
48+
<details>
49+
<summary>Hint 1</summary>
50+
Binary search for the length of the answer. (If there's an answer of length 10, then there are answers of length 9, 8, 7, ...)
51+
</details>
52+
<details>
53+
<summary>Hint 2</summary>
54+
To check whether an answer of length K exists, we can use Rabin-Karp 's algorithm.
55+
</details>

problems/partition-array-for-maximum-sum/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,16 @@
3232
<li><code>1 &lt;= K &lt;= A.length&nbsp;&lt;= 500</code></li>
3333
<li><code>0 &lt;= A[i] &lt;= 10^6</code></li>
3434
</ol>
35+
36+
### Related Topics
37+
[[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)]
38+
39+
### Hints
40+
<details>
41+
<summary>Hint 1</summary>
42+
Think dynamic programming: dp[i] will be the answer for array A[0], ..., A[i-1].
43+
</details>
44+
<details>
45+
<summary>Hint 2</summary>
46+
For j = 1 .. k that keeps everything in bounds, dp[i] is the maximum of dp[i-j] + max(A[i-1], ..., A[i-j]) * j .
47+
</details>

problems/robot-bounded-in-circle/README.md

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,33 +28,30 @@
2828
<p><strong>Example 1:</strong></p>
2929

3030
<pre>
31-
<strong>Input: </strong><span id="example-input-1-1">&quot;GGLLGG&quot;</span>
32-
<strong>Output: </strong><span id="example-output-1">true</span>
31+
<strong>Input: </strong>&quot;GGLLGG&quot;
32+
<strong>Output: </strong>true
3333
<strong>Explanation: </strong>
3434
The robot moves from (0,0) to (0,2), turns 180 degrees, and then returns to (0,0).
3535
When repeating these instructions, the robot remains in the circle of radius 2 centered at the origin.
3636
</pre>
3737

38-
<div>
3938
<p><strong>Example 2:</strong></p>
4039

4140
<pre>
42-
<strong>Input: </strong><span id="example-input-2-1">&quot;GG&quot;</span>
43-
<strong>Output: </strong><span id="example-output-2">false</span>
41+
<strong>Input: </strong>&quot;GG&quot;
42+
<strong>Output: </strong>false
4443
<strong>Explanation: </strong>
45-
The robot moves north indefinetely.
44+
The robot moves north indefinitely.
4645
</pre>
4746

48-
<div>
4947
<p><strong>Example 3:</strong></p>
5048

5149
<pre>
52-
<strong>Input: </strong><span id="example-input-3-1">&quot;GL&quot;</span>
53-
<strong>Output: </strong><span id="example-output-3">true</span>
50+
<strong>Input: </strong>&quot;GL&quot;
51+
<strong>Output: </strong>true
5452
<strong>Explanation: </strong>
5553
The robot moves from (0, 0) -&gt; (0, 1) -&gt; (-1, 1) -&gt; (-1, 0) -&gt; (0, 0) -&gt; ...
5654
</pre>
57-
</div>
5855

5956
<p>&nbsp;</p>
6057

@@ -64,4 +61,16 @@ The robot moves from (0, 0) -&gt; (0, 1) -&gt; (-1, 1) -&gt; (-1, 0) -&gt; (0, 0
6461
<li><code>1 &lt;= instructions.length &lt;= 100</code></li>
6562
<li><code>instructions[i]</code> is in <code>{&#39;G&#39;, &#39;L&#39;, &#39;R&#39;}</code></li>
6663
</ol>
67-
</div>
64+
65+
### Related Topics
66+
[[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)]
67+
68+
### Hints
69+
<details>
70+
<summary>Hint 1</summary>
71+
Calculate the final vector of how the robot travels after executing all instructions once - it consists of a change in position plus a change in direction.
72+
</details>
73+
<details>
74+
<summary>Hint 2</summary>
75+
The robot stays in the circle iff (looking at the final vector) it changes direction (ie. doesn't stay pointing north), or it moves 0.
76+
</details>

0 commit comments

Comments
 (0)