更新 0344.反转字符串 排版格式修复

This commit is contained in:
jinbudaily
2023-07-19 15:32:11 +08:00
parent 4ae88432ed
commit 00ef6084c6

View File

@ -26,10 +26,12 @@
输入:["H","a","n","n","a","h"] 输入:["H","a","n","n","a","h"]
输出:["h","a","n","n","a","H"] 输出:["h","a","n","n","a","H"]
## 算法公开课
# 思路 **[《代码随想录》算法视频公开课](https://programmercarl.com/other/gongkaike.html)[字符串基础操作! | LeetCode344.反转字符串](https://www.bilibili.com/video/BV1fV4y17748),相信结合视频再看本篇题解,更有助于大家对本题的理解**。
针对本题,我录制了视频讲解:[字符串基础操作! | LeetCode344.反转字符串](https://www.bilibili.com/video/BV1fV4y17748),结合本题解一起看,事半功倍!
## 思路
先说一说题外话: 先说一说题外话:
@ -138,8 +140,8 @@ public:
## 其他语言版本 ## 其他语言版本
### Java
Java
```Java ```Java
class Solution { class Solution {
public void reverseString(char[] s) { public void reverseString(char[] s) {
@ -173,8 +175,9 @@ class Solution {
``` ```
Python ### Python
(版本一) 双指针 (版本一) 双指针
```python ```python
class Solution: class Solution:
def reverseString(self, s: List[str]) -> None: def reverseString(self, s: List[str]) -> None:
@ -247,7 +250,8 @@ class Solution:
s[:] = [s[i] for i in range(len(s) - 1, -1, -1)] s[:] = [s[i] for i in range(len(s) - 1, -1, -1)]
``` ```
Go ### Go
```Go ```Go
func reverseString(s []byte) { func reverseString(s []byte) {
left := 0 left := 0
@ -260,7 +264,7 @@ func reverseString(s []byte) {
} }
``` ```
javaScript: ### JavaScript:
```js ```js
/** /**
@ -278,7 +282,7 @@ var reverse = function(s) {
}; };
``` ```
TypeScript ### TypeScript
```typescript ```typescript
/** /**
@ -299,7 +303,7 @@ function reverseString(s: string[]): void {
}; };
``` ```
Swift: ### Swift:
```swift ```swift
// 双指针 - 元组 // 双指针 - 元组
@ -316,7 +320,8 @@ func reverseString(_ s: inout [Character]) {
``` ```
Rust: ### Rust:
```Rust ```Rust
impl Solution { impl Solution {
pub fn reverse_string(s: &mut Vec<char>) { pub fn reverse_string(s: &mut Vec<char>) {
@ -332,7 +337,8 @@ impl Solution {
} }
``` ```
C: ### C:
```c ```c
void reverseString(char* s, int sSize){ void reverseString(char* s, int sSize){
int left = 0; int left = 0;
@ -347,7 +353,8 @@ void reverseString(char* s, int sSize){
} }
``` ```
C# ### C#
```csharp ```csharp
public class Solution public class Solution
{ {
@ -361,8 +368,8 @@ public class Solution
} }
``` ```
### PHP
PHP
```php ```php
// 双指针 // 双指针
// 一: // 一:
@ -392,7 +399,8 @@ function reverse(&$s, $start, $end) {
} }
``` ```
Scala: ### Scala:
```scala ```scala
object Solution { object Solution {
def reverseString(s: Array[Char]): Unit = { def reverseString(s: Array[Char]): Unit = {
@ -411,4 +419,3 @@ object Solution {
<a href="https://programmercarl.com/other/kstar.html" target="_blank"> <a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/> <img src="../pics/网站星球宣传海报.jpg" width="1000"/>
</a> </a>