mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 03:34:02 +08:00
rename the object class name of Scala Solution 2
This commit is contained in:
@ -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"]
|
||||
|
Reference in New Issue
Block a user