javascript 순열과 조합 알고리즘
조합은 배열에서 n개를 선택하는 것으로 순서가 바뀌어도 같은 것으로 취급한다. 순열은 배열에서 n개를 선택해 나열하는 것으로, 순서가 바뀌면 다른 것으로 취급한다. 자바스크립트 조합 알고리즘 const combination = (arr, select) => { const answer = []; const dfs = (idx, num, tmp, visited) => { if(idx === arr.length){ return; } if(num === 0){ answer.push(tmp); } for(let i = idx; i < arr.length; i++){ if(!visited[i]){ // 미방문 visited[i] = true; dfs(i, num - 1, tmp.concat([arr[i]]), vi..