添加(0344.反转字符串.md):增加typescript版本

This commit is contained in:
Steve2020
2022-01-15 16:32:29 +08:00
parent 6de5da719d
commit d9ffaec8a8

View File

@ -201,6 +201,27 @@ var reverseString = function(s) {
};
```
TypeScript
```typescript
/**
Do not return anything, modify s in-place instead.
*/
function reverseString(s: string[]): void {
let length: number = s.length;
let left: number = 0,
right: number = length - 1;
let tempStr: string;
while (left < right) {
tempStr = s[left];
s[left] = s[right];
s[right] = tempStr;
left++;
right--;
}
};
```
Swift:
```swift