rename the object class name of Scala Solution 2

This commit is contained in:
Jijie LIU
2022-10-19 22:23:50 +02:00
committed by GitHub
parent 77b431d276
commit 7278b038c6

View File

@ -401,7 +401,7 @@ object Solution {
```
版本二: 首先利用grouped每隔k个进行分割再使用zipWithIndex添加每个数组的索引紧接着利用map做变换如果索引%2==0则说明需要翻转否则原封不动最后再转换为String
```scala
object SolutionFunc {
object Solution {
def reverseStr(s: String, k: Int): String = {
// s = "abcdefg", k = 2
s.grouped(k) // Iterator ["ab", "cd", "ef", "g"]