Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 38b080d

Browse files
author
Shuo
committed
A: new
1 parent aad7846 commit 38b080d

File tree

32 files changed

+459
-56
lines changed

32 files changed

+459
-56
lines changed

‎README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,26 @@ LeetCode Problems' Solutions
6262

6363
| # | Title | Solution | Difficulty |
6464
| :-: | - | - | :-: |
65-
| <span id="1467">1467</span> | [Probability of a Two Boxes Having The Same Number of Distinct Balls](https://leetcode.com/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls "两个盒子中不同颜色的球数量相同的概率") | [Go](problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | Hard |
65+
| <span id="1473">1473</span> | [Paint House III](https://leetcode.com/problems/paint-house-iii "给房子涂色 III") | [Go](problems/paint-house-iii) | Hard |
66+
| <span id="1472">1472</span> | [Design Browser History](https://leetcode.com/problems/design-browser-history "设计浏览器历史记录") | [Go](problems/design-browser-history) | Medium |
67+
| <span id="1471">1471</span> | [The k Strongest Values in an Array](https://leetcode.com/problems/the-k-strongest-values-in-an-array "数组中的 k 个最强值") | [Go](problems/the-k-strongest-values-in-an-array) | Medium |
68+
| <span id="1470">1470</span> | [Shuffle the Array](https://leetcode.com/problems/shuffle-the-array "重新排列数组") | [Go](problems/shuffle-the-array) | Easy |
69+
| <span id="1469">1469</span> | [Find All The Lonely Nodes](https://leetcode.com/problems/find-all-the-lonely-nodes) 🔒 | [Go](problems/find-all-the-lonely-nodes) | Easy |
70+
| <span id="1468">1468</span> | [Calculate Salaries](https://leetcode.com/problems/calculate-salaries) 🔒 | [MySQL](problems/calculate-salaries) | Medium |
71+
| <span id="1467">1467</span> | [Probability of a Two Boxes Having The Same Number of Distinct Balls](https://leetcode.com/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls "两个盒子中球的颜色数相同的概率") | [Go](problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls) | Hard |
6672
| <span id="1466">1466</span> | [Reorder Routes to Make All Paths Lead to the City Zero](https://leetcode.com/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero "重新规划路线") | [Go](problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero) | Medium |
6773
| <span id="1465">1465</span> | [Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts](https://leetcode.com/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts "切割后面积最大的蛋糕") | [Go](problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts) | Medium |
6874
| <span id="1464">1464</span> | [Maximum Product of Two Elements in an Array](https://leetcode.com/problems/maximum-product-of-two-elements-in-an-array "数组中两元素的最大乘积") | [Go](problems/maximum-product-of-two-elements-in-an-array) | Easy |
6975
| <span id="1463">1463</span> | [Cherry Pickup II](https://leetcode.com/problems/cherry-pickup-ii "摘樱桃 II") | [Go](problems/cherry-pickup-ii) | Hard |
7076
| <span id="1462">1462</span> | [Course Schedule IV](https://leetcode.com/problems/course-schedule-iv "课程安排 IV") | [Go](problems/course-schedule-iv) | Medium |
71-
| <span id="1461">1461</span> | [Check If a String Contains All Binary Codes of Size K](https://leetcode.com/problems/check-if-a-string-contains-all-binary-codes-of-size-k "检查一个字符串是否包含所有大小为 K 的二进制子串") | [Go](problems/check-if-a-string-contains-all-binary-codes-of-size-k) | Medium |
77+
| <span id="1461">1461</span> | [Check If a String Contains All Binary Codes of Size K](https://leetcode.com/problems/check-if-a-string-contains-all-binary-codes-of-size-k "检查一个字符串是否包含所有长度为 K 的二进制子串") | [Go](problems/check-if-a-string-contains-all-binary-codes-of-size-k) | Medium |
7278
| <span id="1460">1460</span> | [Make Two Arrays Equal by Reversing Sub-arrays](https://leetcode.com/problems/make-two-arrays-equal-by-reversing-sub-arrays "通过翻转子数组使两个数组相等") | [Go](problems/make-two-arrays-equal-by-reversing-sub-arrays) | Easy |
73-
| <span id="1459">1459</span> | [Rectangles Area](https://leetcode.com/problems/rectangles-area) 🔒 | [MySQL](problems/rectangles-area) | Medium |
79+
| <span id="1459">1459</span> | [Rectangles Area](https://leetcode.com/problems/rectangles-area"矩形面积") 🔒 | [MySQL](problems/rectangles-area) | Medium |
7480
| <span id="1458">1458</span> | [Max Dot Product of Two Subsequences](https://leetcode.com/problems/max-dot-product-of-two-subsequences "两个子序列的最大点积") | [Go](problems/max-dot-product-of-two-subsequences) | Hard |
7581
| <span id="1457">1457</span> | [Pseudo-Palindromic Paths in a Binary Tree](https://leetcode.com/problems/pseudo-palindromic-paths-in-a-binary-tree "二叉树中的伪回文路径") | [Go](problems/pseudo-palindromic-paths-in-a-binary-tree) | Medium |
7682
| <span id="1456">1456</span> | [Maximum Number of Vowels in a Substring of Given Length](https://leetcode.com/problems/maximum-number-of-vowels-in-a-substring-of-given-length "定长子串中元音的最大数目") | [Go](problems/maximum-number-of-vowels-in-a-substring-of-given-length) | Medium |
7783
| <span id="1455">1455</span> | [Check If a Word Occurs As a Prefix of Any Word in a Sentence](https://leetcode.com/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence "检查单词是否为句中其他单词的前缀") | [Go](problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence) | Easy |
78-
| <span id="1454">1454</span> | [Active Users](https://leetcode.com/problems/active-users) 🔒 | [MySQL](problems/active-users) | Medium |
84+
| <span id="1454">1454</span> | [Active Users](https://leetcode.com/problems/active-users" 活跃用户") 🔒 | [MySQL](problems/active-users) | Medium |
7985
| <span id="1453">1453</span> | [Maximum Number of Darts Inside of a Circular Dartboard](https://leetcode.com/problems/maximum-number-of-darts-inside-of-a-circular-dartboard "圆形靶内的最大飞镖数量") | [Go](problems/maximum-number-of-darts-inside-of-a-circular-dartboard) | Hard |
8086
| <span id="1452">1452</span> | [People Whose List of Favorite Companies Is Not a Subset of Another List](https://leetcode.com/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list "收藏清单") | [Go](problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list) | Medium |
8187
| <span id="1451">1451</span> | [Rearrange Words in a Sentence](https://leetcode.com/problems/rearrange-words-in-a-sentence "重新排列句子中的单词") | [Go](problems/rearrange-words-in-a-sentence) | Medium |

‎problems/active-users/README.md

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

1010
[Next >](../check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence "Check If a Word Occurs As a Prefix of Any Word in a Sentence")
1111

12-
## [1454. Active Users (Medium)](https://leetcode.com/problems/active-users "")
12+
## [1454. Active Users (Medium)](https://leetcode.com/problems/active-users " 活跃用户")
1313

1414

‎problems/calculate-salaries/README.md

Lines changed: 14 additions & 0 deletions
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 <openset.wang@gmail.com> |-->
4+
<!--|@link https://github.com/openset |-->
5+
<!--|@home https://github.com/openset/leetcode |-->
6+
<!--+----------------------------------------------------------------------+-->
7+
8+
[< Previous](../probability-of-a-two-boxes-having-the-same-number-of-distinct-balls "Probability of a Two Boxes Having The Same Number of Distinct Balls")
9+
10+
[Next >](../find-all-the-lonely-nodes "Find All The Lonely Nodes")
11+
12+
## [1468. Calculate Salaries (Medium)](https://leetcode.com/problems/calculate-salaries "")
13+
14+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Create table If Not Exists Salaries (company_id int, employee_id int, employee_name varchar(13), salary int);
2+
Truncate table Salaries;
3+
insert into Salaries (company_id, employee_id, employee_name, salary) values ('1', '1', 'Tony', '2000');
4+
insert into Salaries (company_id, employee_id, employee_name, salary) values ('1', '2', 'Pronub', '21300');
5+
insert into Salaries (company_id, employee_id, employee_name, salary) values ('1', '3', 'Tyrrox', '10800');
6+
insert into Salaries (company_id, employee_id, employee_name, salary) values ('2', '1', 'Pam', '300');
7+
insert into Salaries (company_id, employee_id, employee_name, salary) values ('2', '7', 'Bassem', '450');
8+
insert into Salaries (company_id, employee_id, employee_name, salary) values ('2', '9', 'Hermione', '700');
9+
insert into Salaries (company_id, employee_id, employee_name, salary) values ('3', '7', 'Bocaben', '100');
10+
insert into Salaries (company_id, employee_id, employee_name, salary) values ('3', '2', 'Ognjen', '2200');
11+
insert into Salaries (company_id, employee_id, employee_name, salary) values ('3', '13', 'Nyancat', '3300');
12+
insert into Salaries (company_id, employee_id, employee_name, salary) values ('3', '15', 'Morninngcat', '7777');

‎problems/cheapest-flights-within-k-stops/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
## [787. Cheapest Flights Within K Stops (Medium)](https://leetcode.com/problems/cheapest-flights-within-k-stops "K 站中转内最便宜的航班")
1313

14-
<p>There are <code>n</code> cities connected by&nbsp;<code>m</code> flights. Each flight starts from city&nbsp;<code>u</code>and arrives at&nbsp;<code>v</code> with a price <code>w</code>.</p>
14+
<p>There are <code>n</code> cities connected by&nbsp;<code>m</code> flights. Each flight starts from city&nbsp;<code>u</code>and arrives at&nbsp;<code>v</code> with a price <code>w</code>.</p>
1515

1616
<p>Now given all the cities and flights, together with starting city <code>src</code> and the destination&nbsp;<code>dst</code>, your task is to find the cheapest price from <code>src</code> to <code>dst</code> with up to <code>k</code> stops. If there is no such route, output <code>-1</code>.</p>
1717

@@ -37,9 +37,11 @@ src = 0, dst = 2, k = 0
3737
The graph looks like this:
3838
<img alt="" src="https://s3-lc-upload.s3.amazonaws.com/uploads/2018/02/16/995.png" style="height:180px; width:246px" />
3939

40-
The cheapest price from city <code>0</code> to city <code>2</code> with at most 0 stop costs 500, as marked blue in the picture.</pre>
40+
The cheapest price from city <code>0</code> to city <code>2</code> with at most 0 stop costs 500, as marked blue in the picture.
41+
</pre>
4142

42-
<p><strong>Note:</strong></p>
43+
<p>&nbsp;</p>
44+
<p><strong>Constraints:</strong></p>
4345

4446
<ul>
4547
<li>The number of&nbsp;nodes&nbsp;<code>n</code> will be&nbsp;in range <code>[1, 100]</code>, with nodes labeled from <code>0</code> to <code>n</code><code> - 1</code>.</li>

‎problems/continuous-subarray-sum/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,12 @@
3232
</pre>
3333

3434
<p>&nbsp;</p>
35+
<p><strong>Constraints:</strong></p>
3536

36-
<p><b>Note:</b></p>
37-
38-
<ol>
37+
<ul>
3938
<li>The length of the array won&#39;t exceed 10,000.</li>
4039
<li>You may assume the sum of all the numbers is in the range of a signed 32-bit integer.</li>
41-
</ol>
40+
</ul>
4241

4342
### Related Topics
4443
[[Math](../../tag/math/README.md)]

‎problems/decode-string/README.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,20 @@
1919

2020
<p>Furthermore, you may assume that the original data does not contain any digits and that digits are only for those repeat numbers, <i>k</i>. For example, there won&#39;t be input like <code>3a</code> or <code>2[4]</code>.</p>
2121

22-
<p><b>Examples:</b></p>
23-
24-
<pre>
25-
s = &quot;3[a]2[bc]&quot;, return &quot;aaabcbc&quot;.
26-
s = &quot;3[a2[c]]&quot;, return &quot;accaccacc&quot;.
27-
s = &quot;2[abc]3[cd]ef&quot;, return &quot;abcabccdcdcdef&quot;.
28-
</pre>
29-
3022
<p>&nbsp;</p>
23+
<p><strong>Example 1:</strong></p>
24+
<pre><strong>Input:</strong> s = "3[a]2[bc]"
25+
<strong>Output:</strong> "aaabcbc"
26+
</pre><p><strong>Example 2:</strong></p>
27+
<pre><strong>Input:</strong> s = "3[a2[c]]"
28+
<strong>Output:</strong> "accaccacc"
29+
</pre><p><strong>Example 3:</strong></p>
30+
<pre><strong>Input:</strong> s = "2[abc]3[cd]ef"
31+
<strong>Output:</strong> "abcabccdcdcdef"
32+
</pre><p><strong>Example 4:</strong></p>
33+
<pre><strong>Input:</strong> s = "abc3[cd]xyz"
34+
<strong>Output:</strong> "abccdcdcdxyz"
35+
</pre>
3136

3237
### Related Topics
3338
[[Stack](../../tag/stack/README.md)]

‎problems/delete-leaves-with-a-given-value/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ After removing, new nodes become leaf nodes with value (target = 2) (Picture in
6565

6666
<ul>
6767
<li><code>1 &lt;= target&nbsp;&lt;= 1000</code></li>
68-
<li>Each tree has at most <code>3000</code>nodes.</li>
68+
<li>The&nbsp;given binary tree will have between&nbsp;<code>1</code>&nbsp;and&nbsp;<code>3000</code>&nbsp;nodes.</li>
6969
<li>Each node&#39;s value is between <code>[1, 1000]</code>.</li>
7070
</ul>
7171

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author openset <openset.wang@gmail.com> |-->
4+
<!--|@link https://github.com/openset |-->
5+
<!--|@home https://github.com/openset/leetcode |-->
6+
<!--+----------------------------------------------------------------------+-->
7+
8+
[< Previous](../the-k-strongest-values-in-an-array "The k Strongest Values in an Array")
9+
10+
[Next >](../paint-house-iii "Paint House III")
11+
12+
## [1472. Design Browser History (Medium)](https://leetcode.com/problems/design-browser-history "设计浏览器历史记录")
13+
14+
<p>You have a <strong>browser</strong> of one tab where you start on the <code>homepage</code> and you can visit another <code>url</code>, get back in the history number of <code>steps</code> or move forward in the history number of <code>steps</code>.</p>
15+
16+
<p>Implement the <code>BrowserHistory</code> class:</p>
17+
18+
<ul>
19+
<li><code>BrowserHistory(string homepage)</code> Initializes the object with the <code>homepage</code>&nbsp;of the browser.</li>
20+
<li><code>void visit(string url)</code>&nbsp;visits <code>url</code> from the current page. It clears up all the forward history.</li>
21+
<li><code>string back(int steps)</code>&nbsp;Move <code>steps</code> back in history. If you can only return <code>x</code> steps in the history and <code>steps &gt; x</code>, you will&nbsp;return only <code>x</code> steps. Return the current <code>url</code>&nbsp;after moving back in history <strong>at most</strong> <code>steps</code>.</li>
22+
<li><code>string forward(int steps)</code>&nbsp;Move <code>steps</code> forward in history. If you can only forward <code>x</code> steps in the history and <code>steps &gt; x</code>, you will&nbsp;forward only&nbsp;<code>x</code> steps. Return the current <code>url</code>&nbsp;after forwarding in history <strong>at most</strong> <code>steps</code>.</li>
23+
</ul>
24+
25+
<p>&nbsp;</p>
26+
<p><strong>Example:</strong></p>
27+
28+
<pre>
29+
<b>Input:</b>
30+
[&quot;BrowserHistory&quot;,&quot;visit&quot;,&quot;visit&quot;,&quot;visit&quot;,&quot;back&quot;,&quot;back&quot;,&quot;forward&quot;,&quot;visit&quot;,&quot;forward&quot;,&quot;back&quot;,&quot;back&quot;]
31+
[[&quot;leetcode.com&quot;],[&quot;google.com&quot;],[&quot;facebook.com&quot;],[&quot;youtube.com&quot;],[1],[1],[1],[&quot;linkedin.com&quot;],[2],[2],[7]]
32+
<b>Output:</b>
33+
[null,null,null,null,&quot;facebook.com&quot;,&quot;google.com&quot;,&quot;facebook.com&quot;,null,&quot;linkedin.com&quot;,&quot;google.com&quot;,&quot;leetcode.com&quot;]
34+
35+
<b>Explanation:</b>
36+
BrowserHistory browserHistory = new BrowserHistory(&quot;leetcode.com&quot;);
37+
browserHistory.visit(&quot;google.com&quot;); // You are in &quot;leetcode.com&quot;. Visit &quot;google.com&quot;
38+
browserHistory.visit(&quot;facebook.com&quot;); // You are in &quot;google.com&quot;. Visit &quot;facebook.com&quot;
39+
browserHistory.visit(&quot;youtube.com&quot;); // You are in &quot;facebook.com&quot;. Visit &quot;youtube.com&quot;
40+
browserHistory.back(1); // You are in &quot;youtube.com&quot;, move back to &quot;facebook.com&quot; return &quot;facebook.com&quot;
41+
browserHistory.back(1); // You are in &quot;facebook.com&quot;, move back to &quot;google.com&quot; return &quot;google.com&quot;
42+
browserHistory.forward(1); // You are in &quot;google.com&quot;, move forward to &quot;facebook.com&quot; return &quot;facebook.com&quot;
43+
browserHistory.visit(&quot;linkedin.com&quot;); // You are in &quot;facebook.com&quot;. Visit &quot;linkedin.com&quot;
44+
browserHistory.forward(2); // You are in &quot;linkedin.com&quot;, you cannot move forward any steps.
45+
browserHistory.back(2); // You are in &quot;linkedin.com&quot;, move back two steps to &quot;facebook.com&quot; then to &quot;google.com&quot;. return &quot;google.com&quot;
46+
browserHistory.back(7); // You are in &quot;google.com&quot;, you can move back only one step to &quot;leetcode.com&quot;. return &quot;leetcode.com&quot;
47+
</pre>
48+
49+
<p>&nbsp;</p>
50+
<p><strong>Constraints:</strong></p>
51+
52+
<ul>
53+
<li><code>1 &lt;= homepage.length &lt;= 20</code></li>
54+
<li><code>1 &lt;= url.length &lt;= 20</code></li>
55+
<li><code>1 &lt;= steps &lt;= 100</code></li>
56+
<li><code>homepage</code> and <code>url</code> consist of&nbsp; &#39;.&#39; or lower case English letters.</li>
57+
<li>At most <code>5000</code>&nbsp;calls will be made to <code>visit</code>, <code>back</code>, and <code>forward</code>.</li>
58+
</ul>
59+
60+
### Related Topics
61+
[[Design](../../tag/design/README.md)]
62+
63+
### Hints
64+
<details>
65+
<summary>Hint 1</summary>
66+
Use two stack one for back history and one for forward history and simulate the functions.
67+
</details>
68+
69+
<details>
70+
<summary>Hint 2</summary>
71+
Can you do faster by using different data structure ?
72+
</details>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author openset <openset.wang@gmail.com> |-->
4+
<!--|@link https://github.com/openset |-->
5+
<!--|@home https://github.com/openset/leetcode |-->
6+
<!--+----------------------------------------------------------------------+-->
7+
8+
[< Previous](../calculate-salaries "Calculate Salaries")
9+
10+
[Next >](../shuffle-the-array "Shuffle the Array")
11+
12+
## [1469. Find All The Lonely Nodes (Easy)](https://leetcode.com/problems/find-all-the-lonely-nodes "")
13+
14+
15+
16+
### Related Topics
17+
[[Tree](../../tag/tree/README.md)]
18+
[[Depth-first Search](../../tag/depth-first-search/README.md)]
19+
20+
### Hints
21+
<details>
22+
<summary>Hint 1</summary>
23+
Do a simple tree traversal, try to check if the current node is lonely or not.
24+
</details>
25+
26+
<details>
27+
<summary>Hint 2</summary>
28+
Node is lonely if at least one of the left/right pointers is null.
29+
</details>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /