Skip to content

Add: new #588

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 16, 2019
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
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ LeetCode Problems' Solutions

| # | Title | Solution | Difficulty |
| :-: | - | - | :-: |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
Expand Down
1 change: 1 addition & 0 deletions problems/add-digits/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Could you do it without any loop/recursion in O(1) runtime?</p>

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

### Hints
<details>
Expand Down
2 changes: 1 addition & 1 deletion problems/binary-tree-cameras/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
</div>

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

### Similar Questions
1. [Distribute Coins in Binary Tree](https://github.com/openset/leetcode/tree/master/problems/distribute-coins-in-binary-tree) (Medium)
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

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

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

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

Expand Down
70 changes: 70 additions & 0 deletions problems/confusing-number-ii/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
<!--+----------------------------------------------------------------------+-->
<!--|@author Openset <[email protected]> |-->
<!--|@link https://github.com/openset |-->
<!--|@home https://github.com/openset/leetcode |-->
<!--+----------------------------------------------------------------------+-->

[< Previous](https://github.com/openset/leetcode/tree/master/problems/brace-expansion "Brace Expansion")

[Next >](https://github.com/openset/leetcode/tree/master/problems/duplicate-zeros "Duplicate Zeros")

## 1088. Confusing Number II (Hard)

<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>

<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>

<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>

<p>&nbsp;</p>

<p><strong>Example 1:</strong></p>

<pre>
<strong>Input: </strong><span id="example-input-1-1">20</span>
<strong>Output: </strong><span id="example-output-1">6</span>
<strong>Explanation: </strong>
The confusing numbers are [6,9,10,16,18,19].
6 converts to 9.
9 converts to 6.
10 converts to 01 which is just 1.
16 converts to 91.
18 converts to 81.
19 converts to 61.
</pre>

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

<pre>
<strong>Input: </strong><span id="example-input-2-1">100</span>
<strong>Output: </strong><span id="example-output-2">19</span>
<strong>Explanation: </strong>
The confusing numbers are [6,9,10,16,18,19,60,61,66,68,80,81,86,89,90,91,98,99,100].
</pre>

<p>&nbsp;</p>

<p><strong>Note:</strong></p>

<ol>
<li><code>1 &lt;= N &lt;= 10^9</code></li>
</ol>

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

### Similar Questions
1. [Confusing Number](https://github.com/openset/leetcode/tree/master/problems/confusing-number) (Easy)

### Hints
<details>
<summary>Hint 1</summary>
Which set of digits have the valid numbers?
</details>

<details>
<summary>Hint 2</summary>
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.
</details>
1 change: 1 addition & 0 deletions problems/decode-string/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ s = "2[abc]3[cd]ef", return "abcabccdcdcdef".
### Similar Questions
1. [Encode String with Shortest Length](https://github.com/openset/leetcode/tree/master/problems/encode-string-with-shortest-length) (Hard)
1. [Number of Atoms](https://github.com/openset/leetcode/tree/master/problems/number-of-atoms) (Hard)
1. [Permutation of Letters](https://github.com/openset/leetcode/tree/master/problems/permutation-of-letters) (Medium)
45 changes: 45 additions & 0 deletions problems/duplicate-zeros/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
<!--+----------------------------------------------------------------------+-->
<!--|@author Openset <[email protected]> |-->
<!--|@link https://github.com/openset |-->
<!--|@home https://github.com/openset/leetcode |-->
<!--+----------------------------------------------------------------------+-->

[< Previous](https://github.com/openset/leetcode/tree/master/problems/confusing-number-ii "Confusing Number II")

[Next >](https://github.com/openset/leetcode/tree/master/problems/largest-values-from-labels "Largest Values From Labels")

## 1089. Duplicate Zeros (Easy)

<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>

<p>Note that elements beyond the length of the original array are not written.</p>

<p>Do the above modifications to the input array <strong>in place</strong>, do not return anything from your function.</p>

<p>&nbsp;</p>

<p><strong>Example 1:</strong></p>

<pre>
<strong>Input: </strong><span id="example-input-1-1">[1,0,2,3,0,4,5,0]</span>
<strong>Output: </strong>null
<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>
</pre>

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

<pre>
<strong>Input: </strong><span id="example-input-2-1">[1,2,3]</span>
<strong>Output: </strong>null
<strong>Explanation: </strong>After calling your function, the <strong>input</strong> array is modified to: <span id="example-output-2">[1,2,3]</span>
</pre>

<p>&nbsp;</p>

<p><strong>Note:</strong></p>

<ol>
<li><code>1 &lt;= arr.length &lt;= 10000</code></li>
<li><code>0 &lt;= arr[i] &lt;= 9</code></li>
</ol>
2 changes: 1 addition & 1 deletion problems/encode-and-decode-tinyurl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<!--|@home https://github.com/openset/leetcode |-->
<!--+----------------------------------------------------------------------+-->

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

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

Expand Down
2 changes: 1 addition & 1 deletion problems/find-bottom-left-tree-value/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<!--|@home https://github.com/openset/leetcode |-->
<!--+----------------------------------------------------------------------+-->

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

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

Expand Down
35 changes: 35 additions & 0 deletions problems/high-five/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
<!--+----------------------------------------------------------------------+-->
<!--|@author Openset <[email protected]> |-->
<!--|@link https://github.com/openset |-->
<!--|@home https://github.com/openset/leetcode |-->
<!--+----------------------------------------------------------------------+-->

[< Previous](https://github.com/openset/leetcode/tree/master/problems/sum-of-digits-in-the-minimum-number "Sum of Digits in the Minimum Number")

[Next >](https://github.com/openset/leetcode/tree/master/problems/brace-expansion "Brace Expansion")

## 1086. High Five (Easy)



### Related Topics
[[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)]
[[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)]
[[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)]

### Hints
<details>
<summary>Hint 1</summary>
How can we solve the problem if we have just one student?
</details>

<details>
<summary>Hint 2</summary>
Given an student sort their grades and get the top 5 average.
</details>

<details>
<summary>Hint 3</summary>
Generalize the idea to do it for many students.
</details>
2 changes: 1 addition & 1 deletion problems/inorder-successor-in-bst-ii/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion problems/k-closest-points-to-origin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ We only want the closest K = 1 points from the origin, so the answer is just [[-
</div>

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

### Similar Questions
1. [Kth Largest Element in an Array](https://github.com/openset/leetcode/tree/master/problems/kth-largest-element-in-an-array) (Medium)
Expand Down
2 changes: 1 addition & 1 deletion problems/largest-perimeter-triangle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
</div>

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

### Similar Questions
1. [Largest Triangle Area](https://github.com/openset/leetcode/tree/master/problems/largest-triangle-area) (Easy)
75 changes: 75 additions & 0 deletions problems/largest-values-from-labels/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
<!--+----------------------------------------------------------------------+-->
<!--|@author Openset <[email protected]> |-->
<!--|@link https://github.com/openset |-->
<!--|@home https://github.com/openset/leetcode |-->
<!--+----------------------------------------------------------------------+-->

[< Previous](https://github.com/openset/leetcode/tree/master/problems/duplicate-zeros "Duplicate Zeros")

[Next >](https://github.com/openset/leetcode/tree/master/problems/shortest-path-in-binary-matrix "Shortest Path in Binary Matrix")

## 1090. Largest Values From Labels (Medium)

<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>

<p>Then, we choose&nbsp;a subset <code>S</code> of these items, such that:</p>

<ul>
<li><code>|S| &lt;= num_wanted</code></li>
<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>
</ul>

<p>Return the largest possible sum of the subset <code>S</code>.</p>

<p>&nbsp;</p>

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

<pre>
<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>
<strong>Output: </strong><span id="example-output-1">9</span>
<strong>Explanation: </strong>The subset chosen is the first, third, and fifth item.
</pre>

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

<pre>
<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>
<strong>Output: </strong><span id="example-output-2">12</span>
<strong>Explanation: </strong>The subset chosen is the first, second, and third item.
</pre>

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

<pre>
<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>
<strong>Output:</strong>&nbsp;16
<strong>Explanation: </strong>The subset chosen is the first and fourth item.
</pre>

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

<pre>
<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>
<strong>Output: </strong><span id="example-output-4">24</span>
<strong>Explanation: </strong>The subset chosen is the first, second, and fourth item.
</pre>

<p>&nbsp;</p>

<p><strong>Note:</strong></p>

<ol>
<li><code>1 &lt;= values.length == labels.length &lt;= 20000</code></li>
<li><code>0 &lt;= values[i], labels[i]&nbsp;&lt;= 20000</code></li>
<li><code>1 &lt;= num_wanted, use_limit&nbsp;&lt;= values.length</code></li>
</ol>
</div>
</div>
</div>
</div>
1 change: 1 addition & 0 deletions problems/letter-case-permutation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@

### Similar Questions
1. [Subsets](https://github.com/openset/leetcode/tree/master/problems/subsets) (Medium)
1. [Permutation of Letters](https://github.com/openset/leetcode/tree/master/problems/permutation-of-letters) (Medium)
2 changes: 1 addition & 1 deletion problems/lonely-pixel-ii/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

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

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

## 533. Lonely Pixel II (Medium)

Expand Down
2 changes: 1 addition & 1 deletion problems/minimum-area-rectangle-ii/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@
</ol>

### Related Topics
[[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)]
[[Geometry](https://github.com/openset/leetcode/tree/master/tag/geometry/README.md)]
[[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)]
2 changes: 1 addition & 1 deletion problems/odd-even-jump/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ We can reach the end from starting indexes 1, 2, and 4.
</ol>

### Related Topics
[[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)]
[[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)]
[[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)]
[[Ordered Map](https://github.com/openset/leetcode/tree/master/tag/ordered-map/README.md)]
2 changes: 1 addition & 1 deletion problems/pancake-sorting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ Note that other answers, such as [3, 3], would also be accepted.
</ol>

### Related Topics
[[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)]
[[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)]
[[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)]
Loading