👩💻 Join our community of thousands of amazing developers!
47.全排列 II题目描述:给出一个可包含重复数字的序列nums,长度为 n ,按照任意顺序返回所有不重复的全排列。数据范围: 1\le n \le 8,-10 \le nums[i] \le 10 题解:首先如果不存在重复数字,就是一个普通的全排列。无须剪枝,直接dfs就好,如题目46. 全排列。12345678910111213141516171819202122232425262728293031323334class Solution{public: const static int maxn = 1e5 + 10; const static int maxm = 1e5 + 10; const static int INF = 0x3f3f3f3f; vector<vector<int>> ans; vector<bool> vis; void dfs(int step, vector<int> &nums, vector<int> cur) { if (step == nums.size()) { ...