auto commit
This commit is contained in:
parent
17ef716406
commit
6929c3b862
|
@ -316,6 +316,15 @@ public boolean isSubsequence(String s, String t) {
|
||||||
|
|
||||||
[Leetcode : 763. Partition Labels (Medium)](https://leetcode.com/problems/partition-labels/description/)
|
[Leetcode : 763. Partition Labels (Medium)](https://leetcode.com/problems/partition-labels/description/)
|
||||||
|
|
||||||
|
```java
|
||||||
|
Input: S = "ababcbacadefegdehijhklij"
|
||||||
|
Output: [9,7,8]
|
||||||
|
Explanation:
|
||||||
|
The partition is "ababcbaca", "defegde", "hijhklij".
|
||||||
|
This is a partition so that each letter appears in at most one part.
|
||||||
|
A partition like "ababcbacadefegde", "hijhklij" is incorrect, because it splits S into less parts.
|
||||||
|
```
|
||||||
|
|
||||||
```java
|
```java
|
||||||
public List<Integer> partitionLabels(String S) {
|
public List<Integer> partitionLabels(String S) {
|
||||||
List<Integer> ret = new ArrayList<>();
|
List<Integer> ret = new ArrayList<>();
|
||||||
|
@ -338,6 +347,8 @@ public List<Integer> partitionLabels(String S) {
|
||||||
|
|
||||||
**根据身高和序号重组队列**
|
**根据身高和序号重组队列**
|
||||||
|
|
||||||
|
[Leetcode : 406. Queue Reconstruction by Height(Medium)](https://leetcode.com/problems/queue-reconstruction-by-height/description/)
|
||||||
|
|
||||||
```html
|
```html
|
||||||
Input:
|
Input:
|
||||||
[[7,0], [4,4], [7,1], [5,0], [6,1], [5,2]]
|
[[7,0], [4,4], [7,1], [5,0], [6,1], [5,2]]
|
||||||
|
@ -346,9 +357,11 @@ Output:
|
||||||
[[5,0], [7,0], [5,2], [6,1], [4,4], [7,1]]
|
[[5,0], [7,0], [5,2], [6,1], [4,4], [7,1]]
|
||||||
```
|
```
|
||||||
|
|
||||||
一个学生用两个分量 (h, k) 描述,h 表示身高,k 表示排在前面的有 k 个学生的身高比他高或者和他一样高。
|
题目描述:一个学生用两个分量 (h, k) 描述,h 表示身高,k 表示排在前面的有 k 个学生的身高比他高或者和他一样高。
|
||||||
|
|
||||||
先排序:身高降序、k 值升序,然后按排好序的顺序插入队列的第 k 个位置中。
|
为了在每次插入操作时不影响后续的操作,身高较高的学生应该先做插入操作,否则身高较小的学生原先正确插入第 k 个位置可能会变成第 k+1 个位置。
|
||||||
|
|
||||||
|
身高降序、k 值升序,然后按排好序的顺序插入队列的第 k 个位置中。
|
||||||
|
|
||||||
```java
|
```java
|
||||||
public int[][] reconstructQueue(int[][] people) {
|
public int[][] reconstructQueue(int[][] people) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user