47 Permutations II
来源:互联网 发布:阿里云空间登陆 编辑:程序博客网 时间:2024/05/16 06:56
public class Solution { List<List<Integer>> res = new ArrayList<List<Integer>>();public List<List<Integer>> permuteUnique(int[] nums) { if(nums==null||nums.length==0){ return res; } Arrays.sort(nums); ArrayList<Integer> tmp = new ArrayList<Integer>(); dfs(tmp,0,nums); return res; }void dfs(List<Integer> tmp, int depth, int[] nums){int len = nums.length;if(depth==len){res.add(tmp);return;}for(int i=0;i<len;++i){if(i==0||nums[i]!=nums[i-1]){int c1 = 0,c2 = 0;int tsize = tmp.size();for(int j=0;j<tsize;++j){if(tmp.get(j)==nums[i]) ++c1;}for(int k=0;k<len;++k){if(nums[k]==nums[i]) ++c2;}if(c1 < c2){List<Integer> tt = new ArrayList<Integer>(tmp);tt.add(nums[i]);dfs(tt, depth + 1, nums);}}}}}
0 0
- [leetcode 47] Permutations II
- leetcode || 47、 Permutations II
- leetcode 47 : Permutations II
- leetcode 47: Permutations II
- 47 Permutations II
- 47Permutations II
- [47]Permutations II
- leetcode 47:Permutations II
- LeetCode_OJ【47】Permutations II
- 【leetcode】【47】Permutations II
- LeetCode 47 - Permutations II
- 【LeetCode-47】Permutations II
- 47Permutations II
- LeetCode 47 Permutations II
- Leetcode 47 Permutations II
- Leetcode 47 Permutations II
- LeetCode 47 Permutations II
- Leetcode 47 Permutations II
- BrainFuck解释器
- HTTP 状态码
- practice it BJP3 Exercise 7.18: wordLengths
- iOS开发-Day33-JSON解析
- linux下rsync的使用
- 47 Permutations II
- c++传CString到c#
- 排序总结
- RHEL 6.5 升级内核至linux kernel-4.0.5
- POJ题目分类
- Light OJ 1348 Aladdin and the Return Journey 树链剖分水题
- javascript
- 替换空格
- Android-NDK环境搭建