Skip to content

Commit

Permalink
添加(0452.用最少数量的箭引爆气球.md):增加typescript版本
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaofei-2020 committed Apr 19, 2022
1 parent eeba178 commit 68e47dc
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion problems/0452.用最少数量的箭引爆气球.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func min(a,b int) int{
}
return a
}
```
```

### Javascript
```Javascript
Expand All @@ -214,7 +214,31 @@ var findMinArrowShots = function(points) {
};
```

### TypeScript

```typescript
function findMinArrowShots(points: number[][]): number {
const length: number = points.length;
if (length === 0) return 0;
points.sort((a, b) => a[0] - b[0]);
let resCount: number = 1;
let right: number = points[0][1]; // 右边界
let tempPoint: number[];
for (let i = 1; i < length; i++) {
tempPoint = points[i];
if (tempPoint[0] > right) {
resCount++;
right = tempPoint[1];
} else {
right = Math.min(right, tempPoint[1]);
}
}
return resCount;
};
```

### C

```c
int cmp(const void *a,const void *b)
{
Expand Down

0 comments on commit 68e47dc

Please sign in to comment.