Skip to content

Commit b010739

Browse files
author
openset
committed
Add: new
1 parent 5160187 commit b010739

File tree

18 files changed

+900
-328
lines changed

18 files changed

+900
-328
lines changed

README.md

Lines changed: 26 additions & 310 deletions
Large diffs are not rendered by default.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author openset <[email protected]> |-->
4+
<!--|@link https://github.com/openset |-->
5+
<!--|@home https://github.com/openset/leetcode |-->
6+
<!--+----------------------------------------------------------------------+-->
7+
8+
[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-knight-moves "Minimum Knight Moves")
9+
                
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-time-to-build-blocks "Minimum Time to Build Blocks")
11+
12+
## [1198. Find Smallest Common Element in All Rows (Medium)](https://leetcode.com/problems/find-smallest-common-element-in-all-rows "")
13+
14+
15+
16+
### Related Topics
17+
[[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)]
18+
[[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)]
19+
20+
### Hints
21+
<details>
22+
<summary>Hint 1</summary>
23+
Notice that each row has no duplicates.
24+
</details>
25+
26+
<details>
27+
<summary>Hint 2</summary>
28+
Is counting the frequency of elements enough to find the answer?
29+
</details>
30+
31+
<details>
32+
<summary>Hint 3</summary>
33+
Use a data structure to count the frequency of elements.
34+
</details>
35+
36+
<details>
37+
<summary>Hint 4</summary>
38+
Find an element whose frequency equals the number of rows.
39+
</details>

problems/fizz-buzz-multithreaded/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
[< Previous](https://github.com/openset/leetcode/tree/master/problems/tournament-winners "Tournament Winners")
99

10-
Next >
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/how-many-apples-can-you-put-into-the-basket "How Many Apples Can You Put into the Basket")
1111

1212
## [1195. Fizz Buzz Multithreaded (Medium)](https://leetcode.com/problems/fizz-buzz-multithreaded "")
1313

problems/game-play-analysis-iii/README.md

Lines changed: 1 addition & 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/encode-and-decode-tinyurl "Encode and Decode TinyURL")
1111

12-
## [534. Game Play Analysis III (Medium)](https://leetcode.com/problems/game-play-analysis-iii "")
12+
## [534. Game Play Analysis III (Medium)](https://leetcode.com/problems/game-play-analysis-iii "游戏玩法分析 III")
1313

1414

1515

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author openset <[email protected]> |-->
4+
<!--|@link https://github.com/openset |-->
5+
<!--|@home https://github.com/openset/leetcode |-->
6+
<!--+----------------------------------------------------------------------+-->
7+
8+
[< Previous](https://github.com/openset/leetcode/tree/master/problems/fizz-buzz-multithreaded "Fizz Buzz Multithreaded")
9+
                
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-knight-moves "Minimum Knight Moves")
11+
12+
## [1196. How Many Apples Can You Put into the Basket (Easy)](https://leetcode.com/problems/how-many-apples-can-you-put-into-the-basket "")
13+
14+
15+
16+
### Related Topics
17+
[[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)]
18+
19+
### Hints
20+
<details>
21+
<summary>Hint 1</summary>
22+
What if you think in a greedy approach?
23+
</details>
24+
25+
<details>
26+
<summary>Hint 2</summary>
27+
The best apple to take in one step is the one with the smallest weight.
28+
</details>
29+
30+
<details>
31+
<summary>Hint 3</summary>
32+
Sort the array and take apples with smaller weight first.
33+
</details>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author openset <[email protected]> |-->
4+
<!--|@link https://github.com/openset |-->
5+
<!--|@home https://github.com/openset/leetcode |-->
6+
<!--+----------------------------------------------------------------------+-->
7+
8+
[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimum-time-to-build-blocks "Minimum Time to Build Blocks")
9+
                
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/ugly-number-iii "Ugly Number III")
11+
12+
## [1200. Minimum Absolute Difference (Easy)](https://leetcode.com/problems/minimum-absolute-difference "")
13+
14+
<p>Given an&nbsp;array&nbsp;of <strong>distinct</strong>&nbsp;integers <code>arr</code>, find all pairs of elements with the minimum absolute difference of any two elements.&nbsp;</p>
15+
16+
<p>Return a list of pairs in ascending order(with respect to pairs), each pair <code>[a, b]</code> follows</p>
17+
18+
<ul>
19+
<li><code>a, b</code> are from <code>arr</code></li>
20+
<li><code>a &lt; b</code></li>
21+
<li><code>b - a</code>&nbsp;equals to the minimum absolute difference of any two elements in <code>arr</code></li>
22+
</ul>
23+
24+
<p>&nbsp;</p>
25+
<p><strong>Example 1:</strong></p>
26+
27+
<pre>
28+
<strong>Input:</strong> arr = [4,2,1,3]
29+
<strong>Output:</strong> [[1,2],[2,3],[3,4]]
30+
<strong>Explanation: </strong>The minimum absolute difference is 1. List all pairs with difference equal to 1 in ascending order.</pre>
31+
32+
<p><strong>Example 2:</strong></p>
33+
34+
<pre>
35+
<strong>Input:</strong> arr = [1,3,6,10,15]
36+
<strong>Output:</strong> [[1,3]]
37+
</pre>
38+
39+
<p><strong>Example 3:</strong></p>
40+
41+
<pre>
42+
<strong>Input:</strong> arr = [3,8,-10,23,19,-4,-14,27]
43+
<strong>Output:</strong> [[-14,-10],[19,23],[23,27]]
44+
</pre>
45+
46+
<p>&nbsp;</p>
47+
<p><strong>Constraints:</strong></p>
48+
49+
<ul>
50+
<li><code>2 &lt;= arr.length &lt;= 10^5</code></li>
51+
<li><code>-10^6 &lt;= arr[i] &lt;= 10^6</code></li>
52+
</ul>
53+
54+
### Related Topics
55+
[[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)]
56+
57+
### Hints
58+
<details>
59+
<summary>Hint 1</summary>
60+
Find the minimum absolute difference between two elements in the array.
61+
</details>
62+
63+
<details>
64+
<summary>Hint 2</summary>
65+
The minimum absolute difference must be a difference between two consecutive elements in the sorted array.
66+
</details>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author openset <[email protected]> |-->
4+
<!--|@link https://github.com/openset |-->
5+
<!--|@home https://github.com/openset/leetcode |-->
6+
<!--+----------------------------------------------------------------------+-->
7+
8+
[< Previous](https://github.com/openset/leetcode/tree/master/problems/how-many-apples-can-you-put-into-the-basket "How Many Apples Can You Put into the Basket")
9+
                
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/find-smallest-common-element-in-all-rows "Find Smallest Common Element in All Rows")
11+
12+
## [1197. Minimum Knight Moves (Medium)](https://leetcode.com/problems/minimum-knight-moves "")
13+
14+
15+
16+
### Related Topics
17+
[[Breadth-first Search](https://github.com/openset/leetcode/tree/master/tag/breadth-first-search/README.md)]
18+
19+
### Hints
20+
<details>
21+
<summary>Hint 1</summary>
22+
You can simulate the movements since the limits are low.
23+
</details>
24+
25+
<details>
26+
<summary>Hint 2</summary>
27+
Is there a search algorithm applicable to this problem?
28+
</details>
29+
30+
<details>
31+
<summary>Hint 3</summary>
32+
Since we want the minimum number of moves, we can use Breadth First Search.
33+
</details>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author openset <[email protected]> |-->
4+
<!--|@link https://github.com/openset |-->
5+
<!--|@home https://github.com/openset/leetcode |-->
6+
<!--+----------------------------------------------------------------------+-->
7+
8+
[< Previous](https://github.com/openset/leetcode/tree/master/problems/find-smallest-common-element-in-all-rows "Find Smallest Common Element in All Rows")
9+
                
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/minimum-absolute-difference "Minimum Absolute Difference")
11+
12+
## [1199. Minimum Time to Build Blocks (Hard)](https://leetcode.com/problems/minimum-time-to-build-blocks "")
13+
14+
15+
16+
### Related Topics
17+
[[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)]
18+
[[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)]
19+
20+
### Hints
21+
<details>
22+
<summary>Hint 1</summary>
23+
A greedy approach will not work as the examples show.
24+
</details>
25+
26+
<details>
27+
<summary>Hint 2</summary>
28+
Try all possible moves using DP.
29+
</details>
30+
31+
<details>
32+
<summary>Hint 3</summary>
33+
For the DP state, dp[i][j] is the minimum time cost to build the first i blocks using j workers.
34+
</details>
35+
36+
<details>
37+
<summary>Hint 4</summary>
38+
In one step you can either assign a worker to a block or choose a number of workers to split.
39+
</details>
40+
41+
<details>
42+
<summary>Hint 5</summary>
43+
If you choose to assign a worker to a block it is always better to assign him to the block with the maximum time so we sort the array before using DP.
44+
</details>
45+
46+
<details>
47+
<summary>Hint 6</summary>
48+
To optimize the solution from O(n^3) to O(n^2) notice that if you choose to split, it is always better to split all the workers you have.
49+
</details>

problems/project-employees-ii/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99

1010
[Next >](https://github.com/openset/leetcode/tree/master/problems/project-employees-iii "Project Employees III")
1111

12-
## [1076. Project Employees II (Easy)](https://leetcode.com/problems/project-employees-ii "")
12+
## [1076. Project Employees II (Easy)](https://leetcode.com/problems/project-employees-ii "项目员工II")
1313

1414

problems/sales-analysis-ii/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99

1010
[Next >](https://github.com/openset/leetcode/tree/master/problems/sales-analysis-iii "Sales Analysis III")
1111

12-
## [1083. Sales Analysis II (Easy)](https://leetcode.com/problems/sales-analysis-ii "1083. 销售分析II")
12+
## [1083. Sales Analysis II (Easy)](https://leetcode.com/problems/sales-analysis-ii "销售分析 II")
1313

1414

0 commit comments

Comments
 (0)