mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 16:54:50 +08:00
添加(0344.反转字符串.md):增加typescript版本
This commit is contained in:
@ -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:
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
|
Reference in New Issue
Block a user