Given the array nums
consisting of 2n
elements in the form [x1,x2,...,xn,y1,y2,...,yn]
.
Return the array in the form [x1,y1,x2,y2,...,xn,yn]
.
class Solution(object): def shuffle(self, nums, n): """ :type nums: List[int] :type n: int :rtype: List[int] """ i = 0 j = n ans = [] while i < n: ans.append(nums[i]) ans.append(nums[j]) i += 1 j += 1 return ans