mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 11:34:46 +08:00
添加 0344.反转字符串.md Scala版本
This commit is contained in:
@ -266,6 +266,20 @@ public class Solution
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Scala:
|
||||
```scala
|
||||
object Solution {
|
||||
def reverseString(s: Array[Char]): Unit = {
|
||||
var (left, right) = (0, s.length - 1)
|
||||
while (left < right) {
|
||||
var tmp = s(left)
|
||||
s(left) = s(right)
|
||||
s(right) = tmp
|
||||
left += 1
|
||||
right -= 1
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
-----------------------
|
||||
<div align="center"><img src=https://code-thinking.cdn.bcebos.com/pics/01二维码一.jpg width=500> </img></div>
|
||||
|
Reference in New Issue
Block a user