diff --git a/README.md b/README.md index 027872c9b..baa87e8c0 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,10 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1054 | [Distant Barcodes](https://leetcode.com/problems/distant-barcodes "距离相等的条形码") | [Go](https://github.com/openset/leetcode/tree/master/problems/distant-barcodes) | Medium | +| 1053 | [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 | +| 1052 | [Grumpy Bookstore Owner](https://leetcode.com/problems/grumpy-bookstore-owner "爱生气的书店老板") | [Go](https://github.com/openset/leetcode/tree/master/problems/grumpy-bookstore-owner) | Medium | +| 1051 | [Height Checker](https://leetcode.com/problems/height-checker "高度检查器") | [Go](https://github.com/openset/leetcode/tree/master/problems/height-checker) | Easy | | 1050 | [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 | | 1049 | [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 | | 1048 | [Longest String Chain](https://leetcode.com/problems/longest-string-chain "最长字符串链") | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-string-chain) | Medium | diff --git a/problems/actors-and-directors-who-cooperated-at-least-three-times/README.md b/problems/actors-and-directors-who-cooperated-at-least-three-times/README.md index 25c6def6d..0173e8888 100644 --- a/problems/actors-and-directors-who-cooperated-at-least-three-times/README.md +++ b/problems/actors-and-directors-who-cooperated-at-least-three-times/README.md @@ -7,7 +7,7 @@ [< Previous](https://github.com/openset/leetcode/tree/master/problems/last-stone-weight-ii "Last Stone Weight II") -Next > +[Next >](https://github.com/openset/leetcode/tree/master/problems/height-checker "Height Checker") ## 1050. Actors and Directors Who Cooperated At Least Three Times (Easy) diff --git a/problems/distant-barcodes/README.md b/problems/distant-barcodes/README.md new file mode 100644 index 000000000..217782f48 --- /dev/null +++ b/problems/distant-barcodes/README.md @@ -0,0 +1,46 @@ + + + + + + + +[< Previous](https://github.com/openset/leetcode/tree/master/problems/previous-permutation-with-one-swap "Previous Permutation With One Swap") + +Next > + +## 1054. Distant Barcodes (Medium) + +
In a warehouse, there is a row of barcodes, where the i-th barcode is barcodes[i].
Rearrange the barcodes so that no two adjacent barcodes are equal. You may return any answer, and it is guaranteed an answer exists.
+ ++ +
Example 1:
+ ++Input: [1,1,1,2,2,2] +Output: [2,1,2,1,2,1] ++ +
Example 2:
+ ++Input: [1,1,1,1,2,2,3,3] +Output: [1,3,1,3,2,1,2,1]+
+ +
Note:
+ +1 <= barcodes.length <= 100001 <= barcodes[i] <= 10000Today, the bookstore owner has a store open for customers.length minutes. Every minute, some number of customers (customers[i]) enter the store, and all those customers leave after the end of that minute.
On some minutes, the bookstore owner is grumpy. If the bookstore owner is grumpy on the i-th minute, grumpy[i] = 1, otherwise grumpy[i] = 0. When the bookstore owner is grumpy, the customers of that minute are not satisfied, otherwise they are satisfied.
The bookstore owner knows a secret technique to keep themselves not grumpy for X minutes straight, but can only use it once.
Return the maximum number of customers that can be satisfied throughout the day.
+ ++ +
Example 1:
+ ++Input: customers = [1,0,1,2,1,1,7,5], grumpy = [0,1,0,1,0,1,0,1], X = 3 +Output: 16 +Explanation: The bookstore owner keeps themselves not grumpy for the last 3 minutes. +The maximum number of customers that can be satisfied = 1 + 1 + 1 + 1 + 7 + 5 = 16. ++ +
+ +
Note:
+ +1 <= X <= customers.length == grumpy.length <= 200000 <= customers[i] <= 10000 <= grumpy[i] <= 1Students are asked to stand in non-decreasing order of heights for an annual photo.
+ +Return the minimum number of students not standing in the right positions. (This is the number of students that must move in order for all students to be standing in non-decreasing order of height.)
+ ++ +
Example 1:
+ ++Input: [1,1,4,2,1,3] +Output: 3 +Explanation: +Students with heights 4, 3 and the last 1 are not standing in the right positions. ++ +
+ +
Note:
+ +1 <= heights.length <= 1001 <= heights[i] <= 100Given an array A of positive integers (not necessarily distinct), return the lexicographically largest permutation that is smaller than A, that can be made with one swap (A swap exchanges the positions of two numbers A[i] and A[j]). If it cannot be done, then return the same array.
+ +
Example 1:
+ ++Input: [3,2,1] +Output: [3,1,2] +Explanation: +Swapping 2 and 1. ++ +
Example 2:
+ ++Input: [1,1,5] +Output: [1,1,5] +Explanation: +This is already the smallest permutation. ++ +
Example 3:
+ ++Input: [1,9,4,6,7] +Output: [1,7,4,6,9] +Explanation: +Swapping 9 and 7. ++ +
Example 4:
+ ++Input: [3,1,1,3] +Output: [1,1,3,3] ++ +
+ +
Note:
+ +1 <= A.length <= 100001 <= A[i] <= 10000