Skip to content

Commit

Permalink
添加(0283.移动零.md):增加typescript版本
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaofei-2020 committed May 26, 2022
1 parent 7c33893 commit c70440a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions problems/0283.移动零.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,27 @@ var moveZeroes = function(nums) {
};
```

TypeScript:

```typescript
function moveZeroes(nums: number[]): void {
const length: number = nums.length;
let slowIndex: number = 0,
fastIndex: number = 0;
while (fastIndex < length) {
if (nums[fastIndex] !== 0) {
nums[slowIndex++] = nums[fastIndex];
};
fastIndex++;
}
while (slowIndex < length) {
nums[slowIndex++] = 0;
}
};
```




-----------------------
<div align="center"><img src=https://code-thinking.cdn.bcebos.com/pics/01二维码一.jpg width=500> </img></div>

0 comments on commit c70440a

Please sign in to comment.