코딩 공부

코딩 인터뷰 퀘스천 완전 분석 - Shuffle the Array 본문

Coding

코딩 인터뷰 퀘스천 완전 분석 - Shuffle the Array

Daily Coding 2020. 10. 13. 02:07

[LeetCode] [Easy] 1470. Shuffle the Array

 

leetcode.com/problems/shuffle-the-array/

 

Shuffle the Array - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

 

 

배열 셔플하기

 

[x1,x2,...,xn,y1,y2,...,yn] 형태의 배열이 있을때 [x1,y1,x2,y2,...,xn,yn] 형태의 배열로 바꾸기 (배열 길이 = 2n)

예) [2,5,1,3,4,7] => [2,3,5,4,1,7]

loop에서 i가 홀수일때는 뒤쪽 반에서 가져오고 짝수일때는 앞쪽 반에서 가져오면 끝

 

 

 

이것도 결과값이 나쁘지 않네요 ㅎㅎ

 

Comments