백트래킹을 이용한 순열 in java
static ArrayList nPkV2(int[] arr,int k){ ArrayList ret = new ArrayList(); boolean[] visited = new boolean[arr.length]; int[] resList = new int[k]; nPkdfsV2(ret,arr,resList,visited,k,0); return ret; } static void nPkdfsV2(ArrayList ret, int[] arr, int[] resList, boolean[] visited, int k,int idx){ if(k==idx){ List tmp = new ArrayList(); for(int i=0;i
2020. 8. 30.