Skip to content

Commit 2a2e503

Browse files
author
openset
committed
Update: questions
1 parent 6ee3c57 commit 2a2e503

File tree

6 files changed

+78
-10
lines changed

6 files changed

+78
-10
lines changed

problems/coloring-a-border/README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
[Next >](https://github.com/openset/leetcode/tree/master/problems/uncrossed-lines "Uncrossed Lines")
1111

12-
## 5040. Coloring A Border (Medium)
12+
## 1034. Coloring A Border (Medium)
1313

1414
<p>Given a 2-dimensional&nbsp;<code>grid</code> of integers, each value in the grid represents the color of the grid square at that location.</p>
1515

@@ -57,3 +57,15 @@
5757
<li><code>0 &lt;= c0 &lt; grid[0].length</code></li>
5858
<li><code>1 &lt;= color &lt;= 1000</code></li>
5959
</ol>
60+
61+
### Related Topics
62+
[[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)]
63+
64+
### Similar Questions
65+
1. [Island Perimeter](https://github.com/openset/leetcode/tree/master/problems/island-perimeter) (Easy)
66+
67+
### Hints
68+
<details>
69+
<summary>Hint 1</summary>
70+
Use a DFS to find every square in the component. Then for each square, color it if it has a neighbor that is outside the grid or a different color.
71+
</details>

problems/edit-distance/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,4 @@ exection -&gt; execution (insert &#39;u&#39;)
5353
1. [One Edit Distance](https://github.com/openset/leetcode/tree/master/problems/one-edit-distance) (Medium)
5454
1. [Delete Operation for Two Strings](https://github.com/openset/leetcode/tree/master/problems/delete-operation-for-two-strings) (Medium)
5555
1. [Minimum ASCII Delete Sum for Two Strings](https://github.com/openset/leetcode/tree/master/problems/minimum-ascii-delete-sum-for-two-strings) (Medium)
56+
1. [Uncrossed Lines](https://github.com/openset/leetcode/tree/master/problems/uncrossed-lines) (Medium)

problems/escape-a-large-maze/README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
Next >
1111

12-
## 5042. Escape a Large Maze (Hard)
12+
## 1036. Escape a Large Maze (Hard)
1313

1414
<p>In a 1 million by 1 million grid, the coordinates of each grid square are <code>(x, y)</code> with <code>0 &lt;= x, y &lt; 10^6</code>.</p>
1515

@@ -49,3 +49,16 @@ Because there are no blocked cells, it&#39;s possible to reach the target square
4949
<li><code>0 &lt;= source[i][j], target[i][j] &lt; 10^6</code></li>
5050
<li><code>source != target</code></li>
5151
</ol>
52+
53+
### Related Topics
54+
[[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)]
55+
56+
### Hints
57+
<details>
58+
<summary>Hint 1</summary>
59+
If we become stuck, there's either a loop around the source or around the target.
60+
</details>
61+
<details>
62+
<summary>Hint 2</summary>
63+
If there is a loop around say, the source, what is the maximum number of squares it can have?
64+
</details>

problems/island-perimeter/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@
4141
### Similar Questions
4242
1. [Max Area of Island](https://github.com/openset/leetcode/tree/master/problems/max-area-of-island) (Medium)
4343
1. [Flood Fill](https://github.com/openset/leetcode/tree/master/problems/flood-fill) (Easy)
44+
1. [Coloring A Border](https://github.com/openset/leetcode/tree/master/problems/coloring-a-border) (Medium)

problems/moving-stones-until-consecutive/README.md

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99

1010
[Next >](https://github.com/openset/leetcode/tree/master/problems/coloring-a-border "Coloring A Border")
1111

12-
## 5039. Moving Stones Until Consecutive (Easy)
12+
## 1033. Moving Stones Until Consecutive (Easy)
1313

1414
<p>Three stones are on a number line at positions <code>a</code>, <code>b</code>, and <code>c</code>.</p>
1515

16-
<p>Each turn, let&#39;s say the stones are currently at positions <code>x, y, z</code> with <code>x &lt; y &lt; z</code>.&nbsp; You pick up the stone at either position <code>x</code> or position <code>z</code>, and move that stone to an integer position <code>k</code>, with <code>x &lt; k &lt; z</code> and <code>k != y</code>.</p>
16+
<p>Each turn, you pick up a stone at an endpoint (ie., either the lowest or highest position stone), and move it to an unoccupied position between those&nbsp;endpoints.&nbsp; Formally, let&#39;s say the stones are currently at positions <code>x, y, z</code> with <code>x &lt; y &lt; z</code>.&nbsp; You pick up the stone at either position <code>x</code> or position <code>z</code>, and move that stone to an integer position <code>k</code>, with <code>x &lt; k &lt; z</code> and <code>k != y</code>.</p>
1717

1818
<p>The game ends when you cannot make any more moves, ie. the stones are in consecutive positions.</p>
1919

@@ -25,21 +25,31 @@
2525

2626
<pre>
2727
<strong>Input: </strong>a = <span id="example-input-1-1">1</span>, b = <span id="example-input-1-2">2</span>, c = <span id="example-input-1-3">5</span>
28-
<strong>Output: </strong><span id="example-output-1">[1, 2]
29-
<strong>Explanation: </strong>Move stone from 5 to 4 then to 3, or we can move it directly to 3.</span>
28+
<strong>Output: </strong><span id="example-output-1">[1,2]</span>
29+
<strong>Explanation: </strong>Move the stone from 5 to 3, or move the stone from 5 to 4 to 3.
3030
</pre>
3131

3232
<div>
3333
<p><strong>Example 2:</strong></p>
3434

3535
<pre>
3636
<strong>Input: </strong>a = <span id="example-input-2-1">4</span>, b = <span id="example-input-2-2">3</span>, c = <span id="example-input-2-3">2</span>
37-
<strong>Output: </strong><span id="example-output-2">[0, 0]
38-
</span><span id="example-output-1"><strong>Explanation: </strong>We cannot make any moves.</span>
37+
<strong>Output: </strong><span id="example-output-2">[0,0]</span>
38+
<strong>Explanation: </strong>We cannot make any moves.
39+
</pre>
40+
41+
<div>
42+
<p><strong>Example 3:</strong></p>
43+
44+
<pre>
45+
<strong>Input: </strong>a = <span id="example-input-3-1">3</span>, b = <span id="example-input-3-2">5</span>, c = <span id="example-input-3-3">1</span>
46+
<strong>Output: </strong><span id="example-output-3">[1,2]</span>
47+
<strong>Explanation: </strong>Move the stone from 1 to 4; or move the stone from 1 to 2 to 4.
3948
</pre>
4049

4150
<p>&nbsp;</p>
4251
</div>
52+
</div>
4353

4454
<p><strong>Note:</strong></p>
4555

@@ -49,3 +59,22 @@
4959
<li><code>1 &lt;= c &lt;= 100</code></li>
5060
<li><code>a != b, b != c, c != a</code></li>
5161
</ol>
62+
63+
<div>
64+
<p>&nbsp;</p>
65+
66+
<div>
67+
<div>&nbsp;</div>
68+
</div>
69+
</div>
70+
71+
### Related Topics
72+
[[Brainteaser](https://github.com/openset/leetcode/tree/master/tag/brainteaser/README.md)]
73+
74+
### Hints
75+
<details>
76+
<summary>Hint 1</summary>
77+
For the minimum: We can always do it in at most 2 moves, by moving one stone next to another, then the third stone next to the other two. When can we do it in 1 move? 0 moves?
78+
79+
For the maximum: Every move, the maximum position minus the minimum position must decrease by at least 1.
80+
</details>

problems/uncrossed-lines/README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
[Next >](https://github.com/openset/leetcode/tree/master/problems/escape-a-large-maze "Escape a Large Maze")
1111

12-
## 5041. Uncrossed Lines (Medium)
12+
## 1035. Uncrossed Lines (Medium)
1313

1414
<p>We write the integers of <code>A</code> and <code>B</code>&nbsp;(in the order they are given) on two separate horizontal lines.</p>
1515

@@ -52,5 +52,17 @@ We cannot draw 3 uncrossed lines, because the line from A[1]=4 to B[2]=4 will in
5252
<ol>
5353
<li><code>1 &lt;= A.length &lt;= 500</code></li>
5454
<li><code>1 &lt;= B.length &lt;= 500</code></li>
55-
<li><font face="monospace">1 &lt;= A[i], B[i] &lt;= 2000</font></li>
55+
<li><code><font face="monospace">1 &lt;= A[i], B[i] &lt;= 2000</font></code></li>
5656
</ol>
57+
58+
### Related Topics
59+
[[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)]
60+
61+
### Similar Questions
62+
1. [Edit Distance](https://github.com/openset/leetcode/tree/master/problems/edit-distance) (Hard)
63+
64+
### Hints
65+
<details>
66+
<summary>Hint 1</summary>
67+
Think dynamic programming. Given an oracle dp(i,j) that tells us how many lines A[i:], B[j:] [the sequence A[i], A[i+1], ... and B[j], B[j+1], ...] are uncrossed, can we write this as a recursion?
68+
</details>

0 commit comments

Comments
 (0)