Skip to content

Commit

Permalink
Merge pull request youngyangyang04#1404 from xiaofei-2020/extra04
Browse files Browse the repository at this point in the history
添加(0283.移动零.md):增加typescript版本
  • Loading branch information
youngyangyang04 authored Jun 28, 2022
2 parents c6a4ea6 + c70440a commit d69eab3
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 d69eab3

Please sign in to comment.