코딩 테스트/leetcode
Shuffle the Array
ornni
2024. 6. 25. 10:00
728x90
반응형
첫번째 코드
시작 인덱스에 대해서 이해하고 있으면 순서대로 넣으면 된다!
class Solution:
def shuffle(self, nums: List[int], n: int) -> List[int]:
index1 = 0
index2 = n
answer = []
for i in range(len(nums) // 2):
answer.append(nums[index1])
answer.append(nums[index2])
index1 += 1
index2 += 1
return answer
통과
링크
https://github.com/ornni/leetcode/tree/main/1470-shuffle-the-array
leetcode/1470-shuffle-the-array at main · ornni/leetcode
Collection of LeetCode questions to ace the coding interview! - Created using [LeetHub v3](https://github.com/raphaelheinz/LeetHub-3.0) - ornni/leetcode
github.com
반응형