Merge pull request #1230 from xiaofei-2020/greed14

添加(0406.根据身高重建队列.md):增加typescript版本
This commit is contained in:
程序员Carl
2022-05-05 10:04:17 +08:00
committed by GitHub

View File

@ -290,6 +290,24 @@ var reconstructQueue = function(people) {
};
```
### TypeScript
```typescript
function reconstructQueue(people: number[][]): number[][] {
people.sort((a, b) => {
if (a[0] === b[0]) return a[1] - b[1];
return b[0] - a[0];
});
const resArr: number[][] = [];
for (let i = 0, length = people.length; i < length; i++) {
resArr.splice(people[i][1], 0, people[i]);
}
return resArr;
};
```
-----------------------
<div align="center"><img src=https://code-thinking.cdn.bcebos.com/pics/01二维码一.jpg width=500> </img></div>