Skip to content

Commit 1d113d9

Browse files
author
openset
committed
Add: new
1 parent 011dd21 commit 1d113d9

File tree

33 files changed

+549
-28
lines changed

33 files changed

+549
-28
lines changed

Diff for: README.md

+13-4
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,18 @@ LeetCode Problems' Solutions
5454

5555
| # | Title | Solution | Difficulty |
5656
| :-: | - | - | :-: |
57+
| <span id="1187">1187</span> | [Make Array Strictly Increasing](https://leetcode.com/problems/make-array-strictly-increasing "使数组严格递增") | [Go](https://github.com/openset/leetcode/tree/master/problems/make-array-strictly-increasing) | Hard |
58+
| <span id="1186">1186</span> | [Maximum Subarray Sum with One Deletion](https://leetcode.com/problems/maximum-subarray-sum-with-one-deletion "删除一次得到子数组最大和") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-subarray-sum-with-one-deletion) | Medium |
59+
| <span id="1185">1185</span> | [Day of the Week](https://leetcode.com/problems/day-of-the-week "一周中的第几天") | [Go](https://github.com/openset/leetcode/tree/master/problems/day-of-the-week) | Easy |
60+
| <span id="1184">1184</span> | [Distance Between Bus Stops](https://leetcode.com/problems/distance-between-bus-stops "公交站间的距离") | [Go](https://github.com/openset/leetcode/tree/master/problems/distance-between-bus-stops) | Easy |
61+
| <span id="1183">1183</span> | [Maximum Number of Ones](https://leetcode.com/problems/maximum-number-of-ones "矩阵中 1 的最大数量") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-number-of-ones) | Hard |
62+
| <span id="1182">1182</span> | [Shortest Distance to Target Color](https://leetcode.com/problems/shortest-distance-to-target-color "与目标颜色间的最短距离") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/shortest-distance-to-target-color) | Medium |
63+
| <span id="1181">1181</span> | [Before and After Puzzle](https://leetcode.com/problems/before-and-after-puzzle "前后拼接") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/before-and-after-puzzle) | Medium |
64+
| <span id="1180">1180</span> | [Count Substrings with Only One Distinct Letter](https://leetcode.com/problems/count-substrings-with-only-one-distinct-letter "统计只含单一字母的子串") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/count-substrings-with-only-one-distinct-letter) | Easy |
65+
| <span id="1179">1179</span> | [Reformat Department Table](https://leetcode.com/problems/reformat-department-table) | [MySQL](https://github.com/openset/leetcode/tree/master/problems/reformat-department-table) | Easy |
5766
| <span id="1178">1178</span> | [Number of Valid Words for Each Puzzle](https://leetcode.com/problems/number-of-valid-words-for-each-puzzle "猜字谜") | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-valid-words-for-each-puzzle) | Hard |
5867
| <span id="1177">1177</span> | [Can Make Palindrome from Substring](https://leetcode.com/problems/can-make-palindrome-from-substring "构建回文串检测") | [Go](https://github.com/openset/leetcode/tree/master/problems/can-make-palindrome-from-substring) | Medium |
59-
| <span id="1176">1176</span> | [Diet Plan Performance](https://leetcode.com/problems/diet-plan-performance "健身计划评估") | [Go](https://github.com/openset/leetcode/tree/master/problems/diet-plan-performance) | Easy |
68+
| <span id="1176">1176</span> | [Diet Plan Performance](https://leetcode.com/problems/diet-plan-performance "健身计划评估") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/diet-plan-performance) | Easy |
6069
| <span id="1175">1175</span> | [Prime Arrangements](https://leetcode.com/problems/prime-arrangements "质数排列") | [Go](https://github.com/openset/leetcode/tree/master/problems/prime-arrangements) | Easy |
6170
| <span id="1174">1174</span> | [Immediate Food Delivery II](https://leetcode.com/problems/immediate-food-delivery-ii) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/immediate-food-delivery-ii) | Medium |
6271
| <span id="1173">1173</span> | [Immediate Food Delivery I](https://leetcode.com/problems/immediate-food-delivery-i) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/immediate-food-delivery-i) | Easy |
@@ -157,14 +166,14 @@ LeetCode Problems' Solutions
157166
| <span id="1078">1078</span> | [Occurrences After Bigram](https://leetcode.com/problems/occurrences-after-bigram "Bigram 分词") | [Go](https://github.com/openset/leetcode/tree/master/problems/occurrences-after-bigram) | Easy |
158167
| <span id="1077">1077</span> | [Project Employees III](https://leetcode.com/problems/project-employees-iii "项目员工 III") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/project-employees-iii) | Medium |
159168
| <span id="1076">1076</span> | [Project Employees II](https://leetcode.com/problems/project-employees-ii) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/project-employees-ii) | Easy |
160-
| <span id="1075">1075</span> | [Project Employees I](https://leetcode.com/problems/project-employees-i) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/project-employees-i) | Easy |
169+
| <span id="1075">1075</span> | [Project Employees I](https://leetcode.com/problems/project-employees-i "项目员工 I") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/project-employees-i) | Easy |
161170
| <span id="1074">1074</span> | [Number of Submatrices That Sum to Target](https://leetcode.com/problems/number-of-submatrices-that-sum-to-target "元素和为目标值的子矩阵数量") | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-submatrices-that-sum-to-target) | Hard |
162171
| <span id="1073">1073</span> | [Adding Two Negabinary Numbers](https://leetcode.com/problems/adding-two-negabinary-numbers "负二进制数相加") | [Go](https://github.com/openset/leetcode/tree/master/problems/adding-two-negabinary-numbers) | Medium |
163172
| <span id="1072">1072</span> | [Flip Columns For Maximum Number of Equal Rows](https://leetcode.com/problems/flip-columns-for-maximum-number-of-equal-rows "按列翻转得到最大值等行数") | [Go](https://github.com/openset/leetcode/tree/master/problems/flip-columns-for-maximum-number-of-equal-rows) | Medium |
164173
| <span id="1071">1071</span> | [Greatest Common Divisor of Strings](https://leetcode.com/problems/greatest-common-divisor-of-strings "字符串的最大公因子") | [Go](https://github.com/openset/leetcode/tree/master/problems/greatest-common-divisor-of-strings) | Easy |
165174
| <span id="1070">1070</span> | [Product Sales Analysis III](https://leetcode.com/problems/product-sales-analysis-iii) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/product-sales-analysis-iii) | Medium |
166175
| <span id="1069">1069</span> | [Product Sales Analysis II](https://leetcode.com/problems/product-sales-analysis-ii "产品销售分析 II") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/product-sales-analysis-ii) | Easy |
167-
| <span id="1068">1068</span> | [Product Sales Analysis I](https://leetcode.com/problems/product-sales-analysis-i) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/product-sales-analysis-i) | Easy |
176+
| <span id="1068">1068</span> | [Product Sales Analysis I](https://leetcode.com/problems/product-sales-analysis-i "产品销售分析 I") 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/product-sales-analysis-i) | Easy |
168177
| <span id="1067">1067</span> | [Digit Count in Range](https://leetcode.com/problems/digit-count-in-range "范围内的数字计数") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/digit-count-in-range) | Hard |
169178
| <span id="1066">1066</span> | [Campus Bikes II](https://leetcode.com/problems/campus-bikes-ii "校园自行车分配 II") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/campus-bikes-ii) | Medium |
170179
| <span id="1065">1065</span> | [Index Pairs of a String](https://leetcode.com/problems/index-pairs-of-a-string "字符串的索引对") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/index-pairs-of-a-string) | Easy |
@@ -295,7 +304,7 @@ LeetCode Problems' Solutions
295304
| <span id="940">940</span> | [Distinct Subsequences II](https://leetcode.com/problems/distinct-subsequences-ii "不同的子序列 II") | [Go](https://github.com/openset/leetcode/tree/master/problems/distinct-subsequences-ii) | Hard |
296305
| <span id="939">939</span> | [Minimum Area Rectangle](https://leetcode.com/problems/minimum-area-rectangle "最小面积矩形") | [Go](https://github.com/openset/leetcode/tree/master/problems/minimum-area-rectangle) | Medium |
297306
| <span id="938">938</span> | [Range Sum of BST](https://leetcode.com/problems/range-sum-of-bst "二叉搜索树的范围和") | [Go](https://github.com/openset/leetcode/tree/master/problems/range-sum-of-bst) | Easy |
298-
| <span id="937">937</span> | [Reorder Log Files](https://leetcode.com/problems/reorder-log-files "重新排列日志文件") | [Go](https://github.com/openset/leetcode/tree/master/problems/reorder-log-files) | Easy |
307+
| <span id="937">937</span> | [Reorder Data in Log Files](https://leetcode.com/problems/reorder-data-in-log-files "重新排列日志文件") | [Go](https://github.com/openset/leetcode/tree/master/problems/reorder-data-in-log-files) | Easy |
299308
| <span id="936">936</span> | [Stamping The Sequence](https://leetcode.com/problems/stamping-the-sequence "戳印序列") | [Go](https://github.com/openset/leetcode/tree/master/problems/stamping-the-sequence) | Hard |
300309
| <span id="935">935</span> | [Knight Dialer](https://leetcode.com/problems/knight-dialer "骑士拨号器") | [Go](https://github.com/openset/leetcode/tree/master/problems/knight-dialer) | Medium |
301310
| <span id="934">934</span> | [Shortest Bridge](https://leetcode.com/problems/shortest-bridge "最短的桥") | [Go](https://github.com/openset/leetcode/tree/master/problems/shortest-bridge) | Medium |

Diff for: problems/before-and-after-puzzle/README.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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/count-substrings-with-only-one-distinct-letter "Count Substrings with Only One Distinct Letter")
9+
                
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/shortest-distance-to-target-color "Shortest Distance to Target Color")
11+
12+
## 1181. Before and After Puzzle (Medium)
13+
14+
15+
16+
### Related Topics
17+
[[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)]
18+
19+
### Hints
20+
<details>
21+
<summary>Hint 1</summary>
22+
What if you check every pair of strings (bruteforce)?
23+
</details>
24+
25+
<details>
26+
<summary>Hint 2</summary>
27+
For every two strings, check if they can form a puzzle by comparing their last and first words.
28+
</details>

Diff for: problems/best-time-to-buy-and-sell-stock-ii/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
<strong>Explanation:</strong> In this case, no transaction is done, i.e. max profit = 0.</pre>
4545

4646
### Related Topics
47-
[[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)]
4847
[[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)]
48+
[[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)]
4949

5050
### Similar Questions
5151
1. [Best Time to Buy and Sell Stock](https://github.com/openset/leetcode/tree/master/problems/best-time-to-buy-and-sell-stock) (Easy)

Diff for: problems/can-make-palindrome-from-substring/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-valid-words-for-each-puzzle "Number of Valid Words for Each Puzzle")
1111

12-
## 5175. Can Make Palindrome from Substring (Medium)
12+
## 1177. Can Make Palindrome from Substring (Medium)
1313

1414
<p>Given a string <code>s</code>, we make queries on substrings of <code>s</code>.</p>
1515

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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/reformat-department-table "Reformat Department Table")
9+
                
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/before-and-after-puzzle "Before and After Puzzle")
11+
12+
## 1180. Count Substrings with Only One Distinct Letter (Easy)
13+
14+
15+
16+
### Related Topics
17+
[[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)]
18+
[[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)]
19+
20+
### Hints
21+
<details>
22+
<summary>Hint 1</summary>
23+
What if we divide the string into substrings containing only one distinct character with maximal lengths?
24+
</details>
25+
26+
<details>
27+
<summary>Hint 2</summary>
28+
Now that you have sub-strings with only one distinct character, Try to come up with a formula that counts the number of its sub-strings.
29+
</details>
30+
31+
<details>
32+
<summary>Hint 3</summary>
33+
Alternatively, Observe that the constraints are small so you can use brute force.
34+
</details>

Diff for: problems/day-of-the-week/README.md

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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/distance-between-bus-stops "Distance Between Bus Stops")
9+
                
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/maximum-subarray-sum-with-one-deletion "Maximum Subarray Sum with One Deletion")
11+
12+
## 1185. Day of the Week (Easy)
13+
14+
<p>Given a date, return the corresponding day of the week for that date.</p>
15+
16+
<p>The input is given as three integers representing the <code>day</code>, <code>month</code> and <code>year</code> respectively.</p>
17+
18+
<p>Return the answer as one of the following values&nbsp;<code>{&quot;Sunday&quot;, &quot;Monday&quot;, &quot;Tuesday&quot;, &quot;Wednesday&quot;, &quot;Thursday&quot;, &quot;Friday&quot;, &quot;Saturday&quot;}</code>.</p>
19+
20+
<p>&nbsp;</p>
21+
<p><strong>Example 1:</strong></p>
22+
23+
<pre>
24+
<strong>Input:</strong> day = 31, month = 8, year = 2019
25+
<strong>Output:</strong> &quot;Saturday&quot;
26+
</pre>
27+
28+
<p><strong>Example 2:</strong></p>
29+
30+
<pre>
31+
<strong>Input:</strong> day = 18, month = 7, year = 1999
32+
<strong>Output:</strong> &quot;Sunday&quot;
33+
</pre>
34+
35+
<p><strong>Example 3:</strong></p>
36+
37+
<pre>
38+
<strong>Input:</strong> day = 15, month = 8, year = 1993
39+
<strong>Output:</strong> &quot;Sunday&quot;
40+
</pre>
41+
42+
<p>&nbsp;</p>
43+
<p><strong>Constraints:</strong></p>
44+
45+
<ul>
46+
<li>The given dates are valid&nbsp;dates between the years <code>1971</code> and <code>2100</code>.</li>
47+
</ul>
48+
49+
### Related Topics
50+
[[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)]
51+
52+
### Hints
53+
<details>
54+
<summary>Hint 1</summary>
55+
Sum up the number of days for the years before the given year.
56+
</details>
57+
58+
<details>
59+
<summary>Hint 2</summary>
60+
Handle the case of a leap year.
61+
</details>
62+
63+
<details>
64+
<summary>Hint 3</summary>
65+
Find the number of days for each month of the given year.
66+
</details>

Diff for: problems/diet-plan-performance/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
[Next >](https://github.com/openset/leetcode/tree/master/problems/can-make-palindrome-from-substring "Can Make Palindrome from Substring")
1111

12-
## 5174. Diet Plan Performance (Easy)
12+
## 1176. Diet Plan Performance (Easy)
1313

1414
<p>A dieter consumes&nbsp;<code>calories[i]</code>&nbsp;calories on the <code>i</code>-th day.&nbsp; For every consecutive sequence of <code>k</code> days, they look at <em>T</em>, the total calories consumed during that sequence of <code>k</code> days:</p>
1515

@@ -44,7 +44,7 @@
4444
<pre>
4545
<strong>Input:</strong> calories = [6,5,0,0], k = 2, lower = 1, upper = 5
4646
<strong>Output:</strong> 0
47-
<strong>Explaination</strong>: calories[0] + calories[1] &gt; upper, calories[2] + calories[3] &lt; lower, total points = 0.
47+
<strong>Explaination</strong>: calories[0] + calories[1] &gt; upper, lower &lt;= calories[1] + calories[2] &lt;= upper, calories[2] + calories[3] &lt; lower, total points = 0.
4848
</pre>
4949

5050
<p>&nbsp;</p>

Diff for: problems/distance-between-bus-stops/README.md

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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/maximum-number-of-ones "Maximum Number of Ones")
9+
                
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/day-of-the-week "Day of the Week")
11+
12+
## 1184. Distance Between Bus Stops (Easy)
13+
14+
<p>A bus&nbsp;has <code>n</code> stops numbered from <code>0</code> to <code>n - 1</code> that form&nbsp;a circle. We know the distance between all pairs of neighboring stops where <code>distance[i]</code> is the distance between the stops number&nbsp;<code>i</code> and <code>(i + 1) % n</code>.</p>
15+
16+
<p>The bus goes along both directions&nbsp;i.e. clockwise and counterclockwise.</p>
17+
18+
<p>Return the shortest distance between the given&nbsp;<code>start</code>&nbsp;and <code>destination</code>&nbsp;stops.</p>
19+
20+
<p>&nbsp;</p>
21+
<p><strong>Example 1:</strong></p>
22+
23+
<p><img alt="" src="https://assets.leetcode.com/uploads/2019/09/03/untitled-diagram-1.jpg" style="width: 388px; height: 240px;" /></p>
24+
25+
<pre>
26+
<strong>Input:</strong> distance = [1,2,3,4], start = 0, destination = 1
27+
<strong>Output:</strong> 1
28+
<strong>Explanation:</strong> Distance between 0 and 1 is 1 or 9, minimum is 1.</pre>
29+
30+
<p>&nbsp;</p>
31+
32+
<p><strong>Example 2:</strong></p>
33+
34+
<p><img alt="" src="https://assets.leetcode.com/uploads/2019/09/03/untitled-diagram-1-1.jpg" style="width: 388px; height: 240px;" /></p>
35+
36+
<pre>
37+
<strong>Input:</strong> distance = [1,2,3,4], start = 0, destination = 2
38+
<strong>Output:</strong> 3
39+
<strong>Explanation:</strong> Distance between 0 and 2 is 3 or 7, minimum is 3.
40+
</pre>
41+
42+
<p>&nbsp;</p>
43+
44+
<p><strong>Example 3:</strong></p>
45+
46+
<p><img alt="" src="https://assets.leetcode.com/uploads/2019/09/03/untitled-diagram-1-2.jpg" style="width: 388px; height: 240px;" /></p>
47+
48+
<pre>
49+
<strong>Input:</strong> distance = [1,2,3,4], start = 0, destination = 3
50+
<strong>Output:</strong> 4
51+
<strong>Explanation:</strong> Distance between 0 and 3 is 6 or 4, minimum is 4.
52+
</pre>
53+
54+
<p>&nbsp;</p>
55+
<p><strong>Constraints:</strong></p>
56+
57+
<ul>
58+
<li><code>1 &lt;= n&nbsp;&lt;= 10^4</code></li>
59+
<li><code>distance.length == n</code></li>
60+
<li><code>0 &lt;= start, destination &lt; n</code></li>
61+
<li><code>0 &lt;= distance[i] &lt;= 10^4</code></li>
62+
</ul>
63+
64+
### Related Topics
65+
[[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)]
66+
67+
### Hints
68+
<details>
69+
<summary>Hint 1</summary>
70+
Find the distance between the two stops if the bus moved in clockwise or counterclockwise directions.
71+
</details>

0 commit comments

Comments
 (0)