Skip to content

Commit 10ef77b

Browse files
author
openset
committed
Add: new
1 parent 0fcd118 commit 10ef77b

File tree

9 files changed

+190
-1
lines changed

9 files changed

+190
-1
lines changed

README.md

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

5555
| # | Title | Solution | Difficulty |
5656
| :-: | - | - | :-: |
57+
| <span id="1049">1049</span> | [Last Stone Weight II](https://leetcode.com/problems/last-stone-weight-ii "最后一块石头的重量 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/last-stone-weight-ii) | Medium |
58+
| <span id="1048">1048</span> | [Longest String Chain](https://leetcode.com/problems/longest-string-chain "最长字符串链") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-string-chain) | Medium |
59+
| <span id="1047">1047</span> | [Remove All Adjacent Duplicates In String](https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string "删除字符串中的所有相邻重复项") | [Go](https://github.com/openset/leetcode/tree/master/problems/remove-all-adjacent-duplicates-in-string) | Easy |
60+
| <span id="1046">1046</span> | [Last Stone Weight](https://leetcode.com/problems/last-stone-weight "最后一块石头的重量") | [Go](https://github.com/openset/leetcode/tree/master/problems/last-stone-weight) | Easy |
61+
| <span id="1045">1045</span> | [Customers Who Bought All Products](https://leetcode.com/problems/customers-who-bought-all-products) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/customers-who-bought-all-products) | Medium |
5762
| <span id="1044">1044</span> | [Longest Duplicate Substring](https://leetcode.com/problems/longest-duplicate-substring "最长重复子串") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-duplicate-substring) | Hard |
5863
| <span id="1043">1043</span> | [Partition Array for Maximum Sum](https://leetcode.com/problems/partition-array-for-maximum-sum "分隔数组以得到最大和") | [Go](https://github.com/openset/leetcode/tree/master/problems/partition-array-for-maximum-sum) | Medium |
5964
| <span id="1042">1042</span> | [Flower Planting With No Adjacent](https://leetcode.com/problems/flower-planting-with-no-adjacent "不邻接植花") | [Go](https://github.com/openset/leetcode/tree/master/problems/flower-planting-with-no-adjacent) | Easy |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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/longest-duplicate-substring "Longest Duplicate Substring")
9+
                
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/last-stone-weight "Last Stone Weight")
11+
12+
## 1045. Customers Who Bought All Products (Medium)
13+
14+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Write your MySQL query statement below
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Create table If Not Exists Customer (customer_id int, product_key int);
2+
Create table Product (product_key int);
3+
Truncate table Customer;
4+
insert into Customer (customer_id, product_key) values ('1', '5');
5+
insert into Customer (customer_id, product_key) values ('2', '6');
6+
insert into Customer (customer_id, product_key) values ('3', '5');
7+
insert into Customer (customer_id, product_key) values ('3', '6');
8+
insert into Customer (customer_id, product_key) values ('1', '6');
9+
Truncate table Product;
10+
insert into Product (product_key) values ('5');
11+
insert into Product (product_key) values ('6');
+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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/longest-string-chain "Longest String Chain")
9+
                
10+
Next >
11+
12+
## 1049. Last Stone Weight II (Medium)
13+
14+
<p>We have a collection of rocks, each rock has a positive integer weight.</p>
15+
16+
<p>Each turn, we choose <strong>any two rocks</strong>&nbsp;and smash them together.&nbsp; Suppose the stones have weights <code>x</code> and <code>y</code> with <code>x &lt;= y</code>.&nbsp; The result of this smash is:</p>
17+
18+
<ul>
19+
<li>If <code>x == y</code>, both stones are totally destroyed;</li>
20+
<li>If <code>x != y</code>, the stone of weight <code>x</code> is totally destroyed, and the stone of weight <code>y</code> has new weight <code>y-x</code>.</li>
21+
</ul>
22+
23+
<p>At the end, there is at most 1 stone left.&nbsp; Return the <strong>smallest possible</strong> weight of this stone (the weight is&nbsp;0 if there are no stones left.)</p>
24+
25+
<p>&nbsp;</p>
26+
27+
<p><strong>Example 1:</strong></p>
28+
29+
<pre>
30+
<strong>Input: </strong>[2,7,4,1,8,1]
31+
<strong>Output: </strong>1
32+
<strong>Explanation: </strong>
33+
We can combine 2 and 4 to get 2 so the array converts to [2,7,1,8,1] then,
34+
we can combine 7 and 8 to get 1 so the array converts to [2,1,1,1] then,
35+
we can combine 2 and 1 to get 1 so the array converts to [1,1,1] then,
36+
we can combine 1 and 1 to get 0 so the array converts to [1] then that&#39;s the optimal value.
37+
</pre>
38+
39+
<p>&nbsp;</p>
40+
41+
<p><strong>Note:</strong></p>
42+
43+
<ol>
44+
<li><code>1 &lt;= stones.length &lt;= 30</code></li>
45+
<li><code>1 &lt;= stones[i] &lt;= 100</code></li>
46+
</ol>

problems/last-stone-weight/README.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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/customers-who-bought-all-products "Customers Who Bought All Products")
9+
                
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/remove-all-adjacent-duplicates-in-string "Remove All Adjacent Duplicates In String")
11+
12+
## 1046. Last Stone Weight (Easy)
13+
14+
<p>We have a collection of rocks, each rock has a positive integer weight.</p>
15+
16+
<p>Each turn, we choose the two <strong>heaviest</strong>&nbsp;rocks&nbsp;and smash them together.&nbsp; Suppose the stones have weights <code>x</code> and <code>y</code> with <code>x &lt;= y</code>.&nbsp; The result of this smash is:</p>
17+
18+
<ul>
19+
<li>If <code>x == y</code>, both stones are totally destroyed;</li>
20+
<li>If <code>x != y</code>, the stone of weight <code>x</code> is totally destroyed, and the stone of weight <code>y</code> has new weight <code>y-x</code>.</li>
21+
</ul>
22+
23+
<p>At the end, there is at most 1 stone left.&nbsp; Return the weight of this stone (or 0 if there are no stones left.)</p>
24+
25+
<p><strong>Note:</strong></p>
26+
27+
<ol>
28+
<li><code>1 &lt;= stones.length &lt;= 30</code></li>
29+
<li><code>1 &lt;= stones[i] &lt;= 1000</code></li>
30+
</ol>

problems/longest-duplicate-substring/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/partition-array-for-maximum-sum "Partition Array for Maximum Sum")
99

10-
Next >
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/customers-who-bought-all-products "Customers Who Bought All Products")
1111

1212
## 1044. Longest Duplicate Substring (Hard)
1313

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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/remove-all-adjacent-duplicates-in-string "Remove All Adjacent Duplicates In String")
9+
                
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/last-stone-weight-ii "Last Stone Weight II")
11+
12+
## 1048. Longest String Chain (Medium)
13+
14+
<p>Given a list of words, each word consists of English lowercase letters.</p>
15+
16+
<p>Let&#39;s say <code>word1</code> is a predecessor of <code>word2</code>&nbsp;if and only if we can add exactly one letter anywhere in <code>word1</code> to make it equal to <code>word2</code>.&nbsp; For example,&nbsp;<code>&quot;abc&quot;</code>&nbsp;is a predecessor of <code>&quot;abac&quot;</code>.</p>
17+
18+
<p>A <em>word chain&nbsp;</em>is a sequence of words <code>[word_1, word_2, ..., word_k]</code>&nbsp;with <code>k &gt;= 1</code>,&nbsp;where <code>word_1</code> is a predecessor of <code>word_2</code>, <code>word_2</code> is a predecessor of <code>word_3</code>, and so on.</p>
19+
20+
<p>Return the longest possible length of a word chain with words chosen from the given list of <code>words</code>.</p>
21+
22+
<p>&nbsp;</p>
23+
24+
<p><strong>Example 1:</strong></p>
25+
26+
<pre>
27+
<strong>Input: </strong><span id="example-input-1-1">[&quot;a&quot;,&quot;b&quot;,&quot;ba&quot;,&quot;bca&quot;,&quot;bda&quot;,&quot;bdca&quot;]</span>
28+
<strong>Output: </strong><span id="example-output-1">4
29+
<strong>Explanation</strong>: one of </span>the longest word chain is &quot;a&quot;,&quot;ba&quot;,&quot;bda&quot;,&quot;bdca&quot;.
30+
</pre>
31+
32+
<p>&nbsp;</p>
33+
34+
<p><strong>Note:</strong></p>
35+
36+
<ol>
37+
<li><code>1 &lt;= words.length &lt;= 1000</code></li>
38+
<li><code>1 &lt;= words[i].length &lt;= 16</code></li>
39+
<li><code>words[i]</code> only consists of English lowercase letters.</li>
40+
</ol>
41+
42+
<div>
43+
<p>&nbsp;</p>
44+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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/last-stone-weight "Last Stone Weight")
9+
                
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/longest-string-chain "Longest String Chain")
11+
12+
## 1047. Remove All Adjacent Duplicates In String (Easy)
13+
14+
<p>Given a string <code>S</code> of lowercase letters, a <em>duplicate removal</em> consists of choosing two adjacent and equal letters, and removing&nbsp;them.</p>
15+
16+
<p>We repeatedly make duplicate removals on S until we no longer can.</p>
17+
18+
<p>Return the final string after all such duplicate removals have been made.&nbsp; It is guaranteed the answer is unique.</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">&quot;abbaca&quot;</span>
26+
<strong>Output: </strong><span id="example-output-1">&quot;ca&quot;</span>
27+
<strong>Explanation: </strong>
28+
For example, in &quot;abbaca&quot; we could remove &quot;bb&quot; since the letters are adjacent and equal, and this is the only possible move.&nbsp; The result of this move is that the string is &quot;aaca&quot;, of which only &quot;aa&quot; is possible, so the final string is &quot;ca&quot;.
29+
</pre>
30+
31+
<p>&nbsp;</p>
32+
33+
<p><strong>Note:</strong></p>
34+
35+
<ol>
36+
<li><code>1 &lt;= S.length &lt;= 20000</code></li>
37+
<li><code>S</code> consists only of English lowercase letters.</li>
38+
</ol>

0 commit comments

Comments
 (0)