public ArrayList<ArrayList<Integer>> permute(int[] num) {
        LinkedList<int[]> mappers = search(num.length);
        ArrayList<ArrayList<Integer>> result = new ArrayList<ArrayList<Integer>>();
        for (int[] mapper : mappers) {
            ArrayList<Integer> tmp = new ArrayList<Integer>();
            for (int i : mapper) {
                tmp.add(num[i]);
            }
            result.add(tmp);
        }

        return result;
    }