Skip to content

Commit 015cdb4

Browse files
author
Shuo
authored
Merge pull request #588 from openset/develop
Add: new
2 parents 71bdf2d + 3ae2e64 commit 015cdb4

File tree

34 files changed

+496
-14
lines changed

34 files changed

+496
-14
lines changed

Diff for: README.md

+11
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ LeetCode Problems' Solutions
5454

5555
| # | Title | Solution | Difficulty |
5656
| :-: | - | - | :-: |
57+
| <span id="1092">1092</span> | [Shortest Common Supersequence](https://leetcode.com/problems/shortest-common-supersequence "最短公共超序列") | [Go](https://github.com/openset/leetcode/tree/master/problems/shortest-common-supersequence) | Hard |
58+
| <span id="1091">1091</span> | [Shortest Path in Binary Matrix](https://leetcode.com/problems/shortest-path-in-binary-matrix "二进制矩阵中的最短路径") | [Go](https://github.com/openset/leetcode/tree/master/problems/shortest-path-in-binary-matrix) | Medium |
59+
| <span id="1090">1090</span> | [Largest Values From Labels](https://leetcode.com/problems/largest-values-from-labels "受标签影响的最大值") | [Go](https://github.com/openset/leetcode/tree/master/problems/largest-values-from-labels) | Medium |
60+
| <span id="1089">1089</span> | [Duplicate Zeros](https://leetcode.com/problems/duplicate-zeros "复写零") | [Go](https://github.com/openset/leetcode/tree/master/problems/duplicate-zeros) | Easy |
61+
| <span id="1088">1088</span> | [Confusing Number II](https://leetcode.com/problems/confusing-number-ii "易混淆数 II") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/confusing-number-ii) | Hard |
62+
| <span id="1087">1087</span> | [Brace Expansion](https://leetcode.com/problems/brace-expansion "字母切换") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/brace-expansion) | Medium |
63+
| <span id="1086">1086</span> | [High Five](https://leetcode.com/problems/high-five "前五科的均分") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/high-five) | Easy |
64+
| <span id="1085">1085</span> | [Sum of Digits in the Minimum Number](https://leetcode.com/problems/sum-of-digits-in-the-minimum-number "最小元素各数位之和") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/sum-of-digits-in-the-minimum-number) | Easy |
65+
| <span id="1084">1084</span> | [Sales Analysis III](https://leetcode.com/problems/sales-analysis-iii) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/sales-analysis-iii) | Easy |
66+
| <span id="1083">1083</span> | [Sales Analysis II](https://leetcode.com/problems/sales-analysis-ii) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/sales-analysis-ii) | Easy |
67+
| <span id="1082">1082</span> | [Sales Analysis I](https://leetcode.com/problems/sales-analysis-i) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/sales-analysis-i) | Easy |
5768
| <span id="1081">1081</span> | [Smallest Subsequence of Distinct Characters](https://leetcode.com/problems/smallest-subsequence-of-distinct-characters "不同字符的最小子序列") | [Go](https://github.com/openset/leetcode/tree/master/problems/smallest-subsequence-of-distinct-characters) | Medium |
5869
| <span id="1080">1080</span> | [Insufficient Nodes in Root to Leaf Paths](https://leetcode.com/problems/insufficient-nodes-in-root-to-leaf-paths "根到叶路径上的不足节点") | [Go](https://github.com/openset/leetcode/tree/master/problems/insufficient-nodes-in-root-to-leaf-paths) | Medium |
5970
| <span id="1079">1079</span> | [Letter Tile Possibilities](https://leetcode.com/problems/letter-tile-possibilities "活字印刷") | [Go](https://github.com/openset/leetcode/tree/master/problems/letter-tile-possibilities) | Medium |

Diff for: problems/add-digits/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Could you do it without any loop/recursion in O(1) runtime?</p>
3030

3131
### Similar Questions
3232
1. [Happy Number](https://github.com/openset/leetcode/tree/master/problems/happy-number) (Easy)
33+
1. [Sum of Digits in the Minimum Number](https://github.com/openset/leetcode/tree/master/problems/sum-of-digits-in-the-minimum-number) (Easy)
3334

3435
### Hints
3536
<details>

Diff for: problems/binary-tree-cameras/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848
</div>
4949

5050
### Related Topics
51-
[[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)]
5251
[[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)]
5352
[[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)]
53+
[[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)]
5454

5555
### Similar Questions
5656
1. [Distribute Coins in Binary Tree](https://github.com/openset/leetcode/tree/master/problems/distribute-coins-in-binary-tree) (Medium)

Diff for: problems/binary-tree-longest-consecutive-sequence-ii/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
[< Previous](https://github.com/openset/leetcode/tree/master/problems/split-array-with-equal-sum "Split Array with Equal Sum")
99

10-
[Next >](https://github.com/openset/leetcode/tree/master/problems/student-attendance-record-i "Student Attendance Record I")
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/game-play-analysis-iv "Game Play Analysis IV")
1111

1212
## 549. Binary Tree Longest Consecutive Sequence II (Medium)
1313

Diff for: problems/confusing-number-ii/README.md

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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/brace-expansion "Brace Expansion")
9+
                
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/duplicate-zeros "Duplicate Zeros")
11+
12+
## 1088. Confusing Number II (Hard)
13+
14+
<p>We can rotate digits by 180 degrees to form new digits. When 0, 1, 6, 8, 9 are rotated 180 degrees, they become 0, 1, 9, 8, 6 respectively. When 2, 3, 4, 5 and 7 are rotated 180 degrees, they become invalid.</p>
15+
16+
<p>A <em>confusing number</em> is a number that when rotated 180 degrees becomes a <strong>different</strong> number with each digit valid.(Note that the rotated number can be greater than the original number.)</p>
17+
18+
<p>Given a positive integer <code>N</code>, return the number of confusing numbers between <code>1</code> and <code>N</code>&nbsp;inclusive.</p>
19+
20+
<p>&nbsp;</p>
21+
22+
<p><strong>Example 1:</strong></p>
23+
24+
<pre>
25+
<strong>Input: </strong><span id="example-input-1-1">20</span>
26+
<strong>Output: </strong><span id="example-output-1">6</span>
27+
<strong>Explanation: </strong>
28+
The confusing numbers are [6,9,10,16,18,19].
29+
6 converts to 9.
30+
9 converts to 6.
31+
10 converts to 01 which is just 1.
32+
16 converts to 91.
33+
18 converts to 81.
34+
19 converts to 61.
35+
</pre>
36+
37+
<p><strong>Example 2:</strong></p>
38+
39+
<pre>
40+
<strong>Input: </strong><span id="example-input-2-1">100</span>
41+
<strong>Output: </strong><span id="example-output-2">19</span>
42+
<strong>Explanation: </strong>
43+
The confusing numbers are [6,9,10,16,18,19,60,61,66,68,80,81,86,89,90,91,98,99,100].
44+
</pre>
45+
46+
<p>&nbsp;</p>
47+
48+
<p><strong>Note:</strong></p>
49+
50+
<ol>
51+
<li><code>1 &lt;= N &lt;= 10^9</code></li>
52+
</ol>
53+
54+
### Related Topics
55+
[[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)]
56+
[[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)]
57+
58+
### Similar Questions
59+
1. [Confusing Number](https://github.com/openset/leetcode/tree/master/problems/confusing-number) (Easy)
60+
61+
### Hints
62+
<details>
63+
<summary>Hint 1</summary>
64+
Which set of digits have the valid numbers?
65+
</details>
66+
67+
<details>
68+
<summary>Hint 2</summary>
69+
Only 0, 1, 6, 8, 9 are the valid set of digits, do a backtracking to generate all the numbers containing this digits and check they are valid.
70+
</details>

Diff for: problems/decode-string/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@ s = "2[abc]3[cd]ef", return "abcabccdcdcdef".
3838
### Similar Questions
3939
1. [Encode String with Shortest Length](https://github.com/openset/leetcode/tree/master/problems/encode-string-with-shortest-length) (Hard)
4040
1. [Number of Atoms](https://github.com/openset/leetcode/tree/master/problems/number-of-atoms) (Hard)
41+
1. [Permutation of Letters](https://github.com/openset/leetcode/tree/master/problems/permutation-of-letters) (Medium)

Diff for: problems/duplicate-zeros/README.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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/confusing-number-ii "Confusing Number II")
9+
                
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/largest-values-from-labels "Largest Values From Labels")
11+
12+
## 1089. Duplicate Zeros (Easy)
13+
14+
<p>Given a fixed length&nbsp;array <code>arr</code> of integers, duplicate each occurrence of zero, shifting the remaining elements to the right.</p>
15+
16+
<p>Note that elements beyond the length of the original array are not written.</p>
17+
18+
<p>Do the above modifications to the input array <strong>in place</strong>, do not return anything from your function.</p>
19+
20+
<p>&nbsp;</p>
21+
22+
<p><strong>Example 1:</strong></p>
23+
24+
<pre>
25+
<strong>Input: </strong><span id="example-input-1-1">[1,0,2,3,0,4,5,0]</span>
26+
<strong>Output: </strong>null
27+
<strong>Explanation: </strong>After calling your function, the <strong>input</strong> array is modified to: <span id="example-output-1">[1,0,0,2,3,0,0,4]</span>
28+
</pre>
29+
30+
<p><strong>Example 2:</strong></p>
31+
32+
<pre>
33+
<strong>Input: </strong><span id="example-input-2-1">[1,2,3]</span>
34+
<strong>Output: </strong>null
35+
<strong>Explanation: </strong>After calling your function, the <strong>input</strong> array is modified to: <span id="example-output-2">[1,2,3]</span>
36+
</pre>
37+
38+
<p>&nbsp;</p>
39+
40+
<p><strong>Note:</strong></p>
41+
42+
<ol>
43+
<li><code>1 &lt;= arr.length &lt;= 10000</code></li>
44+
<li><code>0 &lt;= arr[i] &lt;= 9</code></li>
45+
</ol>

Diff for: problems/encode-and-decode-tinyurl/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<!--|@home https://github.com/openset/leetcode |-->
66
<!--+----------------------------------------------------------------------+-->
77

8-
[< Previous](https://github.com/openset/leetcode/tree/master/problems/lonely-pixel-ii "Lonely Pixel II")
8+
[< Previous](https://github.com/openset/leetcode/tree/master/problems/game-play-analysis-iii "Game Play Analysis III")
99

1010
[Next >](https://github.com/openset/leetcode/tree/master/problems/construct-binary-tree-from-string "Construct Binary Tree from String")
1111

Diff for: problems/find-bottom-left-tree-value/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<!--|@home https://github.com/openset/leetcode |-->
66
<!--+----------------------------------------------------------------------+-->
77

8-
[< Previous](https://github.com/openset/leetcode/tree/master/problems/inorder-successor-in-bst-ii "Inorder Successor in BST II")
8+
[< Previous](https://github.com/openset/leetcode/tree/master/problems/game-play-analysis-ii "Game Play Analysis II")
99

1010
[Next >](https://github.com/openset/leetcode/tree/master/problems/freedom-trail "Freedom Trail")
1111

Diff for: problems/high-five/README.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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/sum-of-digits-in-the-minimum-number "Sum of Digits in the Minimum Number")
9+
                
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/brace-expansion "Brace Expansion")
11+
12+
## 1086. High Five (Easy)
13+
14+
15+
16+
### Related Topics
17+
[[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)]
18+
[[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)]
19+
[[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)]
20+
21+
### Hints
22+
<details>
23+
<summary>Hint 1</summary>
24+
How can we solve the problem if we have just one student?
25+
</details>
26+
27+
<details>
28+
<summary>Hint 2</summary>
29+
Given an student sort their grades and get the top 5 average.
30+
</details>
31+
32+
<details>
33+
<summary>Hint 3</summary>
34+
Generalize the idea to do it for many students.
35+
</details>

Diff for: problems/inorder-successor-in-bst-ii/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
[< Previous](https://github.com/openset/leetcode/tree/master/problems/fibonacci-number "Fibonacci Number")
99

10-
[Next >](https://github.com/openset/leetcode/tree/master/problems/find-bottom-left-tree-value "Find Bottom Left Tree Value")
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/game-play-analysis-i "Game Play Analysis I")
1111

1212
## 510. Inorder Successor in BST II (Medium)
1313

Diff for: problems/k-closest-points-to-origin/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ We only want the closest K = 1 points from the origin, so the answer is just [[-
5454
</div>
5555

5656
### Related Topics
57-
[[Divide and Conquer](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)]
5857
[[Heap](https://github.com/openset/leetcode/tree/master/tag/heap/README.md)]
5958
[[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)]
59+
[[Divide and Conquer](https://github.com/openset/leetcode/tree/master/tag/divide-and-conquer/README.md)]
6060

6161
### Similar Questions
6262
1. [Kth Largest Element in an Array](https://github.com/openset/leetcode/tree/master/problems/kth-largest-element-in-an-array) (Medium)

Diff for: problems/largest-perimeter-triangle/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@
6666
</div>
6767

6868
### Related Topics
69-
[[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)]
7069
[[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)]
70+
[[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)]
7171

7272
### Similar Questions
7373
1. [Largest Triangle Area](https://github.com/openset/leetcode/tree/master/problems/largest-triangle-area) (Easy)

Diff for: problems/largest-values-from-labels/README.md

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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/duplicate-zeros "Duplicate Zeros")
9+
                
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/shortest-path-in-binary-matrix "Shortest Path in Binary Matrix")
11+
12+
## 1090. Largest Values From Labels (Medium)
13+
14+
<p>We have a set of items: the <code>i</code>-th item has value <code>values[i]</code> and label <code>labels[i]</code>.</p>
15+
16+
<p>Then, we choose&nbsp;a subset <code>S</code> of these items, such that:</p>
17+
18+
<ul>
19+
<li><code>|S| &lt;= num_wanted</code></li>
20+
<li>For every label <code>L</code>, the number of items in <code>S</code> with&nbsp;label <code>L</code> is <code>&lt;= use_limit</code>.</li>
21+
</ul>
22+
23+
<p>Return the largest possible sum of the subset <code>S</code>.</p>
24+
25+
<p>&nbsp;</p>
26+
27+
<div>
28+
<p><strong>Example 1:</strong></p>
29+
30+
<pre>
31+
<strong>Input: </strong>values = <span id="example-input-1-1">[5,4,3,2,1]</span>, labels = <span id="example-input-1-2">[1,1,2,2,3]</span>, <code>num_wanted </code>= <span id="example-input-1-3">3</span>, use_limit = <span id="example-input-1-4">1</span>
32+
<strong>Output: </strong><span id="example-output-1">9</span>
33+
<strong>Explanation: </strong>The subset chosen is the first, third, and fifth item.
34+
</pre>
35+
36+
<div>
37+
<p><strong>Example 2:</strong></p>
38+
39+
<pre>
40+
<strong>Input: </strong>values = <span id="example-input-2-1">[5,4,3,2,1]</span>, labels = <span id="example-input-2-2">[1,3,3,3,2]</span>, <code>num_wanted </code>= <span id="example-input-2-3">3</span>, use_limit = <span id="example-input-2-4">2</span>
41+
<strong>Output: </strong><span id="example-output-2">12</span>
42+
<strong>Explanation: </strong>The subset chosen is the first, second, and third item.
43+
</pre>
44+
45+
<div>
46+
<p><strong>Example 3:</strong></p>
47+
48+
<pre>
49+
<strong>Input: </strong>values = <span id="example-input-3-1">[9,8,8,7,6]</span>, labels = <span id="example-input-3-2">[0,0,0,1,1]</span>, <code>num_wanted </code>= <span id="example-input-3-3">3</span>, use_limit = <span id="example-input-3-4">1</span>
50+
<strong>Output:</strong>&nbsp;16
51+
<strong>Explanation: </strong>The subset chosen is the first and fourth item.
52+
</pre>
53+
54+
<div>
55+
<p><strong>Example 4:</strong></p>
56+
57+
<pre>
58+
<strong>Input: </strong>values = <span id="example-input-4-1">[9,8,8,7,6]</span>, labels = <span id="example-input-4-2">[0,0,0,1,1]</span>, <code>num_wanted </code>= <span id="example-input-4-3">3</span>, use_limit = <span id="example-input-4-4">2</span>
59+
<strong>Output: </strong><span id="example-output-4">24</span>
60+
<strong>Explanation: </strong>The subset chosen is the first, second, and fourth item.
61+
</pre>
62+
63+
<p>&nbsp;</p>
64+
65+
<p><strong>Note:</strong></p>
66+
67+
<ol>
68+
<li><code>1 &lt;= values.length == labels.length &lt;= 20000</code></li>
69+
<li><code>0 &lt;= values[i], labels[i]&nbsp;&lt;= 20000</code></li>
70+
<li><code>1 &lt;= num_wanted, use_limit&nbsp;&lt;= values.length</code></li>
71+
</ol>
72+
</div>
73+
</div>
74+
</div>
75+
</div>

Diff for: problems/letter-case-permutation/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@
3838

3939
### Similar Questions
4040
1. [Subsets](https://github.com/openset/leetcode/tree/master/problems/subsets) (Medium)
41+
1. [Permutation of Letters](https://github.com/openset/leetcode/tree/master/problems/permutation-of-letters) (Medium)

Diff for: problems/lonely-pixel-ii/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
[< Previous](https://github.com/openset/leetcode/tree/master/problems/k-diff-pairs-in-an-array "K-diff Pairs in an Array")
99

10-
[Next >](https://github.com/openset/leetcode/tree/master/problems/encode-and-decode-tinyurl "Encode and Decode TinyURL")
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/game-play-analysis-iii "Game Play Analysis III")
1111

1212
## 533. Lonely Pixel II (Medium)
1313

Diff for: problems/minimum-area-rectangle-ii/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,5 @@
7676
</ol>
7777

7878
### Related Topics
79-
[[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)]
8079
[[Geometry](https://github.com/openset/leetcode/tree/master/tag/geometry/README.md)]
80+
[[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)]

Diff for: problems/odd-even-jump/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,6 @@ We can reach the end from starting indexes 1, 2, and 4.
8787
</ol>
8888

8989
### Related Topics
90-
[[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)]
9190
[[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)]
91+
[[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)]
9292
[[Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md)]

Diff for: problems/pancake-sorting/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@ Note that other answers, such as [3, 3], would also be accepted.
5252
</ol>
5353

5454
### Related Topics
55-
[[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)]
5655
[[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)]
56+
[[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)]

0 commit comments

Comments
 (0)