LeetCode - Problems - Algorithms - 1470. Shuffle the Array
Problem Description
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].
Example:
Constraints:
My Solution (Python)
class Solution:
def shuffle(self, nums, n):
answer = []
for x in range(n):
answer.append(nums[x]) # append x element
answer.append(nums[x+n]) # append y element
return answer
'Problem solving > Algorithms' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[LeetCode] 1528. Shuffle String (Python) (0) | 2021.01.10 |
---|---|
[LeetCode] 1512. Number of Good Pairs (Python) (0) | 2021.01.10 |
[LeetCode] 1365. How Many Numbers Are Smaller Than the Current Number (Python) (0) | 2021.01.10 |
[LeetCode] 1108. Defanging an IP Address (Python) (0) | 2021.01.10 |
[LeetCode] 1431. Kids With the Greatest Number of Candies (Python) (0) | 2021.01.09 |