Skip to content

Commit c70440a

Browse files
committed
添加(0283.移动零.md):增加typescript版本
1 parent 7c33893 commit c70440a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

problems/0283.移动零.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,27 @@ var moveZeroes = function(nums) {
133133
};
134134
```
135135

136+
TypeScript:
137+
138+
```typescript
139+
function moveZeroes(nums: number[]): void {
140+
const length: number = nums.length;
141+
let slowIndex: number = 0,
142+
fastIndex: number = 0;
143+
while (fastIndex < length) {
144+
if (nums[fastIndex] !== 0) {
145+
nums[slowIndex++] = nums[fastIndex];
146+
};
147+
fastIndex++;
148+
}
149+
while (slowIndex < length) {
150+
nums[slowIndex++] = 0;
151+
}
152+
};
153+
```
154+
155+
156+
136157

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

0 commit comments

Comments
 (0)