Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions problems/flower-planting-with-no-adjacent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,12 @@
</div>
</div>
</div>

### Related Topics
[[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)]

### Hints
<details>
<summary>Hint 1</summary>
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.
</details>
14 changes: 14 additions & 0 deletions problems/longest-duplicate-substring/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,17 @@ Next >
<li><code>2 &lt;= S.length &lt;= 10^5</code></li>
<li><code>S</code> consists of lowercase English letters.</li>
</ol>

### Related Topics
[[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)]
[[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)]

### Hints
<details>
<summary>Hint 1</summary>
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, ...)
</details>
<details>
<summary>Hint 2</summary>
To check whether an answer of length K exists, we can use Rabin-Karp 's algorithm.
</details>
13 changes: 13 additions & 0 deletions problems/partition-array-for-maximum-sum/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,16 @@
<li><code>1 &lt;= K &lt;= A.length&nbsp;&lt;= 500</code></li>
<li><code>0 &lt;= A[i] &lt;= 10^6</code></li>
</ol>

### Related Topics
[[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)]

### Hints
<details>
<summary>Hint 1</summary>
Think dynamic programming: dp[i] will be the answer for array A[0], ..., A[i-1].
</details>
<details>
<summary>Hint 2</summary>
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 .
</details>
31 changes: 20 additions & 11 deletions problems/robot-bounded-in-circle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,30 @@
<p><strong>Example 1:</strong></p>

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

<div>
<p><strong>Example 2:</strong></p>

<pre>
<strong>Input: </strong><span id="example-input-2-1">&quot;GG&quot;</span>
<strong>Output: </strong><span id="example-output-2">false</span>
<strong>Input: </strong>&quot;GG&quot;
<strong>Output: </strong>false
<strong>Explanation: </strong>
The robot moves north indefinetely.
The robot moves north indefinitely.
</pre>

<div>
<p><strong>Example 3:</strong></p>

<pre>
<strong>Input: </strong><span id="example-input-3-1">&quot;GL&quot;</span>
<strong>Output: </strong><span id="example-output-3">true</span>
<strong>Input: </strong>&quot;GL&quot;
<strong>Output: </strong>true
<strong>Explanation: </strong>
The robot moves from (0, 0) -&gt; (0, 1) -&gt; (-1, 1) -&gt; (-1, 0) -&gt; (0, 0) -&gt; ...
</pre>
</div>

<p>&nbsp;</p>

Expand All @@ -64,4 +61,16 @@ The robot moves from (0, 0) -&gt; (0, 1) -&gt; (-1, 1) -&gt; (-1, 0) -&gt; (0, 0
<li><code>1 &lt;= instructions.length &lt;= 100</code></li>
<li><code>instructions[i]</code> is in <code>{&#39;G&#39;, &#39;L&#39;, &#39;R&#39;}</code></li>
</ol>
</div>

### Related Topics
[[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)]

### Hints
<details>
<summary>Hint 1</summary>
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.
</details>
<details>
<summary>Hint 2</summary>
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.
</details>