Leetcode: Shuffle the Array Solution in Kotlin
1470. Shuffle the Array
Zip the two half lists, flatten.
class Solution {
fun shuffle(nums: IntArray, n: Int) = nums.zip(
nums.drop(n)
).flatMap { it.toList() }
}
Zip the two half lists, flatten.
class Solution {
fun shuffle(nums: IntArray, n: Int) = nums.zip(
nums.drop(n)
).flatMap { it.toList() }
}