HomeAboutMeBlogGuest
© 2025 Sejin Cha. All rights reserved.
Built with Next.js, deployed on Vercel
📝
프론트엔드 스쿨 교안(1기)
/
📝
(코테준비) 자료구조 및 알고리즘
/
✌
JS 100제 - 2권
/
🔥
문제52
/
✔️
답안
✔️

답안

function quickSort(arr){ if (arr.length <= 1){ return arr; } const pivot = arr[0]; //기준점 const left = []; const right = []; for (let i=1; i<arr.length; i++){ if(arr[i] < pivot){ left.push(arr[i]); } else { right.push(arr[i]); } } return quickSort(left).concat(pivot, quickSort(right)); } const array = prompt('배열을 입력하세요').split(' ').map(n => parseInt(n, 10)); console.log(quickSort(array));