题目
给定一个不含重复数字的数组 nums ,返回其 所有可能的全排列 。你可以 按任意顺序 返回答案。

(图片来源网络,侵删)
示例 1:
输入:nums = [1,2,3]

(图片来源网络,侵删)
输出:[[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
解
Class Solution { public list permute(int[] nums) { List result = new ArrayList(); int n = nums.length; boolean[] used = new boolean[n]; LinkedList path = new LinkedList(); dfs(nums, 0, used, path, result); return result; } public void dfs(int[] nums, int index, boolean[] used, LinkedList path, List res) { if (index == nums.length) { res.add(new LinkedList(path)); return; } for (int i = 0; i