Skip to content

Latest commit

 

History

History
18 lines (16 loc) · 415 Bytes

1470.md

File metadata and controls

18 lines (16 loc) · 415 Bytes

1470. Shuffle the Array

Solution 1 (time O(n), space O(1))

class Solution(object):
    def shuffle(self, nums, n):
        """
        :type nums: List[int]
        :type n: int
        :rtype: List[int]
        """
        ans = [0 for _ in range(2 * n)]
        for i in range(n):
            ans[i * 2] = nums[i]
            ans[i * 2 + 1] = nums[n + i]
        return ans