Skip to content

Commit 56f9b4e

Browse files
author
Shuo
authored
Merge pull request #558 from openset/develop
Add: new
2 parents 3c74fcd + 0bee509 commit 56f9b4e

File tree

6 files changed

+187
-1
lines changed

6 files changed

+187
-1
lines changed

README.md

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

5555
| # | Title | Solution | Difficulty |
5656
| :-: | - | - | :-: |
57+
| <span id="1054">1054</span> | [Distant Barcodes](https://leetcode.com/problems/distant-barcodes "距离相等的条形码") | [Go](https://github.com/openset/leetcode/tree/master/problems/distant-barcodes) | Medium |
58+
| <span id="1053">1053</span> | [Previous Permutation With One Swap](https://leetcode.com/problems/previous-permutation-with-one-swap "交换一次的先前排列") | [Go](https://github.com/openset/leetcode/tree/master/problems/previous-permutation-with-one-swap) | Medium |
59+
| <span id="1052">1052</span> | [Grumpy Bookstore Owner](https://leetcode.com/problems/grumpy-bookstore-owner "爱生气的书店老板") | [Go](https://github.com/openset/leetcode/tree/master/problems/grumpy-bookstore-owner) | Medium |
60+
| <span id="1051">1051</span> | [Height Checker](https://leetcode.com/problems/height-checker "高度检查器") | [Go](https://github.com/openset/leetcode/tree/master/problems/height-checker) | Easy |
5761
| <span id="1050">1050</span> | [Actors and Directors Who Cooperated At Least Three Times](https://leetcode.com/problems/actors-and-directors-who-cooperated-at-least-three-times) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/actors-and-directors-who-cooperated-at-least-three-times) | Easy |
5862
| <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 |
5963
| <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 |

problems/actors-and-directors-who-cooperated-at-least-three-times/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
[< Previous](https://github.com/openset/leetcode/tree/master/problems/last-stone-weight-ii "Last Stone Weight II")
99

10-
Next >
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/height-checker "Height Checker")
1111

1212
## 1050. Actors and Directors Who Cooperated At Least Three Times (Easy)
1313

Lines changed: 46 additions & 0 deletions
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 <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/previous-permutation-with-one-swap "Previous Permutation With One Swap")
9+
                
10+
Next >
11+
12+
## 1054. Distant Barcodes (Medium)
13+
14+
<p>In a warehouse, there is a row of barcodes, where the <code>i</code>-th barcode is&nbsp;<code>barcodes[i]</code>.</p>
15+
16+
<p>Rearrange the barcodes so that no two adjacent barcodes are equal.&nbsp; You may return any answer, and it is guaranteed an answer exists.</p>
17+
18+
<p>&nbsp;</p>
19+
20+
<p><strong>Example 1:</strong></p>
21+
22+
<pre>
23+
<strong>Input: </strong><span id="example-input-1-1">[1,1,1,2,2,2]</span>
24+
<strong>Output: </strong><span id="example-output-1">[2,1,2,1,2,1]</span>
25+
</pre>
26+
27+
<div>
28+
<p><strong>Example 2:</strong></p>
29+
30+
<pre>
31+
<strong>Input: </strong><span id="example-input-2-1">[1,1,1,1,2,2,3,3]</span>
32+
<strong>Output: </strong><span id="example-output-2">[1,3,1,3,2,1,2,1]</span></pre>
33+
</div>
34+
35+
<p>&nbsp;</p>
36+
37+
<p><strong>Note:</strong></p>
38+
39+
<ol>
40+
<li><code>1 &lt;= barcodes.length &lt;= 10000</code></li>
41+
<li><code>1 &lt;= barcodes[i] &lt;= 10000</code></li>
42+
</ol>
43+
44+
<div>
45+
<div>&nbsp;</div>
46+
</div>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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/height-checker "Height Checker")
9+
                
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/previous-permutation-with-one-swap "Previous Permutation With One Swap")
11+
12+
## 1052. Grumpy Bookstore Owner (Medium)
13+
14+
<p>Today, the bookstore owner has a store open for <code>customers.length</code> minutes.&nbsp; Every minute, some number of customers (<code>customers[i]</code>) enter the store, and all those customers leave after the end of that minute.</p>
15+
16+
<p>On some minutes, the bookstore owner is grumpy.&nbsp; If the bookstore owner is grumpy on the i-th minute, <code>grumpy[i] = 1</code>, otherwise <code>grumpy[i] = 0</code>.&nbsp; When the bookstore owner is grumpy, the customers of that minute are not satisfied, otherwise they are satisfied.</p>
17+
18+
<p>The bookstore owner knows a secret technique to keep themselves&nbsp;not grumpy for <code>X</code>&nbsp;minutes straight, but can only use it once.</p>
19+
20+
<p>Return the maximum number of customers that can be satisfied throughout the day.</p>
21+
22+
<p>&nbsp;</p>
23+
24+
<p><strong>Example 1:</strong></p>
25+
26+
<pre>
27+
<strong>Input: </strong>customers = [1,0,1,2,1,1,7,5], grumpy = [0,1,0,1,0,1,0,1], X = 3
28+
<strong>Output: </strong>16
29+
<strong>Explanation:</strong>&nbsp;The bookstore owner keeps themselves&nbsp;not grumpy for the last 3 minutes.
30+
The maximum number of customers that can be satisfied = 1 + 1 + 1 + 1 + 7 + 5 = 16.
31+
</pre>
32+
33+
<p>&nbsp;</p>
34+
35+
<p><strong>Note:</strong></p>
36+
37+
<ul>
38+
<li><code>1 &lt;= X &lt;=&nbsp;customers.length ==&nbsp;grumpy.length &lt;= 20000</code></li>
39+
<li><code>0 &lt;=&nbsp;customers[i] &lt;= 1000</code></li>
40+
<li><code>0 &lt;=&nbsp;grumpy[i] &lt;= 1</code></li>
41+
</ul>

problems/height-checker/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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/actors-and-directors-who-cooperated-at-least-three-times "Actors and Directors Who Cooperated At Least Three Times")
9+
                
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/grumpy-bookstore-owner "Grumpy Bookstore Owner")
11+
12+
## 1051. Height Checker (Easy)
13+
14+
<p>Students are asked to stand in non-decreasing order of heights for an annual photo.</p>
15+
16+
<p>Return the minimum number of students not standing in the right positions.&nbsp; (This is the number of students that must move in order for all students to be standing in non-decreasing order of height.)</p>
17+
18+
<p>&nbsp;</p>
19+
20+
<p><strong>Example 1:</strong></p>
21+
22+
<pre>
23+
<strong>Input: </strong>[1,1,4,2,1,3]
24+
<strong>Output: </strong>3
25+
<strong>Explanation: </strong>
26+
Students with heights 4, 3 and the last 1 are not standing in the right positions.
27+
</pre>
28+
29+
<p>&nbsp;</p>
30+
31+
<p><strong>Note:</strong></p>
32+
33+
<ol>
34+
<li><code>1 &lt;= heights.length &lt;= 100</code></li>
35+
<li><code>1 &lt;= heights[i] &lt;= 100</code></li>
36+
</ol>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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/grumpy-bookstore-owner "Grumpy Bookstore Owner")
9+
                
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/distant-barcodes "Distant Barcodes")
11+
12+
## 1053. Previous Permutation With One Swap (Medium)
13+
14+
<p>Given an array <code>A</code> of positive integers (not necessarily distinct), return the lexicographically largest permutation that is smaller than <code>A</code>, that can be <strong>made with one swap</strong> (A <em>swap</em> exchanges the positions of two numbers <code>A[i]</code> and <code>A[j]</code>).&nbsp; If it cannot be done, then return the same array.</p>
15+
16+
<p>&nbsp;</p>
17+
18+
<p><strong>Example 1:</strong></p>
19+
20+
<pre>
21+
<strong>Input: </strong>[3,2,1]
22+
<strong>Output: </strong>[3,1,2]
23+
<strong>Explanation: </strong>
24+
Swapping 2 and 1.
25+
</pre>
26+
27+
<p><strong>Example 2:</strong></p>
28+
29+
<pre>
30+
<strong>Input: </strong>[1,1,5]
31+
<strong>Output: </strong>[1,1,5]
32+
<strong>Explanation: </strong>
33+
This is already the smallest permutation.
34+
</pre>
35+
36+
<p><strong>Example 3:</strong></p>
37+
38+
<pre>
39+
<strong>Input: </strong>[1,9,4,6,7]
40+
<strong>Output: </strong>[1,7,4,6,9]
41+
<strong>Explanation: </strong>
42+
Swapping 9 and 7.
43+
</pre>
44+
45+
<p><strong>Example 4:</strong></p>
46+
47+
<pre>
48+
<strong>Input: </strong>[3,1,1,3]
49+
<strong>Output: </strong>[1,1,3,3]
50+
</pre>
51+
52+
<p>&nbsp;</p>
53+
54+
<p><strong>Note:</strong></p>
55+
56+
<ol>
57+
<li><code>1 &lt;= A.length &lt;= 10000</code></li>
58+
<li><code>1 &lt;= A[i] &lt;= 10000</code></li>
59+
</ol>

0 commit comments

Comments
 (0)