https://leetcode.cn/problems/7p8L0Z/
题目要求
给定一个可包含重复数字的整数集合 nums ,按任意顺序 返回它所有不重复的全排列。
方法:回溯
- 添加之前判断是否已经存在,如果不存在则添加
public List<List<Integer>> permuteUnique(int[] nums) {
List<List<Integer>> res = new ArrayList<>();
int n = nums.length;
backtrack(0, n, nums, res);
return res;
}
public void backtrack(int i, int n, int[] nums, List<List<Integer>> res) {
if (i == n) {