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 ada1c54

Browse files
author
Shuo
authored
Merge pull request #601 from openset/develop
Add: new
2 parents 6884e68 + f9533e5 commit ada1c54

File tree

28 files changed

+299
-13
lines changed

28 files changed

+299
-13
lines changed

‎README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ LeetCode Problems' Solutions
5454

5555
| # | Title | Solution | Difficulty |
5656
| :-: | - | - | :-: |
57+
| <span id="1107">1107</span> | [New Users Daily Count](https://leetcode.com/problems/new-users-daily-count) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/new-users-daily-count) | Medium |
58+
| <span id="1106">1106</span> | [Parsing A Boolean Expression](https://leetcode.com/problems/parsing-a-boolean-expression "解析布尔表达式") | [Go](https://github.com/openset/leetcode/tree/master/problems/parsing-a-boolean-expression) | Hard |
59+
| <span id="1105">1105</span> | [Filling Bookcase Shelves](https://leetcode.com/problems/filling-bookcase-shelves "填充书架") | [Go](https://github.com/openset/leetcode/tree/master/problems/filling-bookcase-shelves) | Medium |
60+
| <span id="1104">1104</span> | [Path In Zigzag Labelled Binary Tree](https://leetcode.com/problems/path-in-zigzag-labelled-binary-tree "二叉树寻路") | [Go](https://github.com/openset/leetcode/tree/master/problems/path-in-zigzag-labelled-binary-tree) | Medium |
61+
| <span id="1103">1103</span> | [Distribute Candies to People](https://leetcode.com/problems/distribute-candies-to-people "分糖果 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/distribute-candies-to-people) | Easy |
5762
| <span id="1102">1102</span> | [Path With Maximum Minimum Value](https://leetcode.com/problems/path-with-maximum-minimum-value "得分最高的路径") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/path-with-maximum-minimum-value) | Medium |
5863
| <span id="1101">1101</span> | [The Earliest Moment When Everyone Become Friends](https://leetcode.com/problems/the-earliest-moment-when-everyone-become-friends "彼此熟识的最早时间") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/the-earliest-moment-when-everyone-become-friends) | Medium |
5964
| <span id="1100">1100</span> | [Find K-Length Substrings With No Repeated Characters](https://leetcode.com/problems/find-k-length-substrings-with-no-repeated-characters "长度为 K 的无重复字符子串") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/find-k-length-substrings-with-no-repeated-characters) | Medium |

‎problems/binary-tree-inorder-traversal/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
<p><strong>Follow up:</strong> Recursive solution is trivial, could you do it iteratively?</p>
2929

3030
### Related Topics
31+
[[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)]
3132
[[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)]
3233
[[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)]
33-
[[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)]
3434

3535
### Similar Questions
3636
1. [Validate Binary Search Tree](https://github.com/openset/leetcode/tree/master/problems/validate-binary-search-tree) (Medium)

‎problems/construct-binary-tree-from-inorder-and-postorder-traversal/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ postorder = [9,15,7,20,3]</pre>
3333
</pre>
3434

3535
### Related Topics
36+
[[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)]
3637
[[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)]
3738
[[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)]
38-
[[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)]
3939

4040
### Similar Questions
4141
1. [Construct Binary Tree from Preorder and Inorder Traversal](https://github.com/openset/leetcode/tree/master/problems/construct-binary-tree-from-preorder-and-inorder-traversal) (Medium)

‎problems/construct-binary-tree-from-preorder-and-inorder-traversal/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ inorder = [9,3,15,20,7]</pre>
3232
15 7</pre>
3333

3434
### Related Topics
35+
[[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)]
3536
[[Tree](https://github.com/openset/leetcode/tree/master/tag/tree/README.md)]
3637
[[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)]
37-
[[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)]
3838

3939
### Similar Questions
4040
1. [Construct Binary Tree from Inorder and Postorder Traversal](https://github.com/openset/leetcode/tree/master/problems/construct-binary-tree-from-inorder-and-postorder-traversal) (Medium)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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](https://github.com/openset/leetcode/tree/master/problems/path-with-maximum-minimum-value "Path With Maximum Minimum Value")
9+
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/path-in-zigzag-labelled-binary-tree "Path In Zigzag Labelled Binary Tree")
11+
12+
## 1103. Distribute Candies to People (Easy)
13+
14+
<p>We distribute some&nbsp;number of <code>candies</code>, to a row of <strong><code>n =&nbsp;num_people</code></strong>&nbsp;people in the following way:</p>
15+
16+
<p>We then give 1 candy to the first person, 2 candies to the second person, and so on until we give <code>n</code>&nbsp;candies to the last person.</p>
17+
18+
<p>Then, we go back to the start of the row, giving <code>n&nbsp;+ 1</code> candies to the first person, <code>n&nbsp;+ 2</code> candies to the second person, and so on until we give <code>2 * n</code>&nbsp;candies to the last person.</p>
19+
20+
<p>This process repeats (with us giving one more candy each time, and moving to the start of the row after we reach the end) until we run out of candies.&nbsp; The last person will receive all of our remaining candies (not necessarily one more than the previous gift).</p>
21+
22+
<p>Return an array (of length <code>num_people</code>&nbsp;and sum <code>candies</code>) that represents the final distribution of candies.</p>
23+
24+
<p>&nbsp;</p>
25+
<p><strong>Example 1:</strong></p>
26+
27+
<pre>
28+
<strong>Input:</strong> candies = 7, num_people = 4
29+
<strong>Output:</strong> [1,2,3,1]
30+
<strong>Explanation:</strong>
31+
On the first turn, ans[0] += 1, and the array is [1,0,0,0].
32+
On the second turn, ans[1] += 2, and the array is [1,2,0,0].
33+
On the third turn, ans[2] += 3, and the array is [1,2,3,0].
34+
On the fourth turn, ans[3] += 1 (because there is only one candy left), and the final array is [1,2,3,1].
35+
</pre>
36+
37+
<p><strong>Example 2:</strong></p>
38+
39+
<pre>
40+
<strong>Input:</strong> candies = 10, num_people = 3
41+
<strong>Output:</strong> [5,2,3]
42+
<strong>Explanation: </strong>
43+
On the first turn, ans[0] += 1, and the array is [1,0,0].
44+
On the second turn, ans[1] += 2, and the array is [1,2,0].
45+
On the third turn, ans[2] += 3, and the array is [1,2,3].
46+
On the fourth turn, ans[0] += 4, and the final array is [5,2,3].
47+
</pre>
48+
49+
<p>&nbsp;</p>
50+
<p><strong>Constraints:</strong></p>
51+
52+
<ul>
53+
<li>1 &lt;= candies &lt;= 10^9</li>
54+
<li>1 &lt;= num_people &lt;= 1000</li>
55+
</ul>
56+
57+
### Related Topics
58+
[[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)]
59+
60+
### Hints
61+
<details>
62+
<summary>Hint 1</summary>
63+
Give candy to everyone each "turn" first [until you can't], then give candy to one person per turn.
64+
</details>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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](https://github.com/openset/leetcode/tree/master/problems/path-in-zigzag-labelled-binary-tree "Path In Zigzag Labelled Binary Tree")
9+
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/parsing-a-boolean-expression "Parsing A Boolean Expression")
11+
12+
## 1105. Filling Bookcase Shelves (Medium)
13+
14+
<p>We have a sequence of <code>books</code>: the <code>i</code>-th book has thickness <code>books[i][0]</code> and height <code>books[i][1]</code>.</p>
15+
16+
<p>We want to place these books <strong>in order</strong>&nbsp;onto bookcase shelves that have total width <code>shelf_width</code>.</p>
17+
18+
<p>We choose&nbsp;some of the books to place on this shelf (such that the sum of their thickness is <code>&lt;= shelf_width</code>), then build another level of shelf of the bookcase so that the total height of the bookcase has increased by the maximum height of the books we just put down.&nbsp; We repeat this process until there are no more books to place.</p>
19+
20+
<p>Note again that at each step of the above&nbsp;process, <u>the order of the books we place is the same order as the given sequence of books</u>.&nbsp; For example, if we have an ordered list of 5&nbsp;books, we might place the first and second book onto the first shelf, the third book on the second shelf, and the fourth and fifth book on the last shelf.</p>
21+
22+
<p>Return the minimum possible height that the total bookshelf can be after placing shelves in this manner.</p>
23+
24+
<p>&nbsp;</p>
25+
<p><strong>Example 1:</strong></p>
26+
<img alt="" src="https://assets.leetcode.com/uploads/2019/06/24/shelves.png" style="width: 250px; height: 370px;" />
27+
<pre>
28+
<strong>Input:</strong> books = [[1,1],[2,3],[2,3],[1,1],[1,1],[1,1],[1,2]], shelf_width = 4
29+
<strong>Output:</strong> 6
30+
<strong>Explanation:</strong>
31+
The sum of the heights of the 3 shelves are 1 + 3 + 2 = 6.
32+
Notice that book number 2 does not have to be on the first shelf.
33+
</pre>
34+
35+
<p>&nbsp;</p>
36+
<p><strong>Constraints:</strong></p>
37+
38+
<ul>
39+
<li><code>1 &lt;= books.length &lt;= 1000</code></li>
40+
<li><code>1 &lt;= books[i][0] &lt;= shelf_width &lt;= 1000</code></li>
41+
<li><code>1 &lt;= books[i][1] &lt;= 1000</code></li>
42+
</ul>
43+
44+
### Related Topics
45+
[[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)]
46+
47+
### Hints
48+
<details>
49+
<summary>Hint 1</summary>
50+
Use dynamic programming: dp(i) will be the answer to the problem for books[i:].
51+
</details>

‎problems/find-k-length-substrings-with-no-repeated-characters/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/the-earliest-moment-when-everyone-become-friends "The Earliest Moment When Everyone Become Friends")
1111

12-
## 5022. Find K-Length Substrings With No Repeated Characters (Medium)
12+
## 1100. Find K-Length Substrings With No Repeated Characters (Medium)
1313

1414
<p>Given a string <code>S</code>, return the number of substrings of length <code>K</code> with no repeated characters.</p>
1515

‎problems/largest-rectangle-in-histogram/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
</pre>
3434

3535
### Related Topics
36-
[[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)]
3736
[[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)]
37+
[[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)]
3838

3939
### Similar Questions
4040
1. [Maximal Rectangle](https://github.com/openset/leetcode/tree/master/problems/maximal-rectangle) (Hard)

‎problems/maximal-rectangle/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
</pre>
2828

2929
### Related Topics
30-
[[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)]
3130
[[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)]
3231
[[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)]
3332
[[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)]
33+
[[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)]
3434

3535
### Similar Questions
3636
1. [Largest Rectangle in Histogram](https://github.com/openset/leetcode/tree/master/problems/largest-rectangle-in-histogram) (Hard)
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](https://github.com/openset/leetcode/tree/master/problems/parsing-a-boolean-expression "Parsing A Boolean Expression")
9+
10+
Next >
11+
12+
## 1107. New Users Daily Count (Medium)
13+
14+

0 commit comments

Comments
(0)

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