LeetCode 047 Permutations II
2024-10-18 19:51:39
题目要求:Permutations II
Given a collection of numbers that might contain duplicates, return all possible unique permutations.
For example,[1,1,2]
have the following unique permutations:[1,1,2]
, [1,2,1]
, and [2,1,1]
.
代码如下:
class Solution {
public:
vector<vector<int> > permuteUnique(vector<int> &num) { vector<vector<int>> result;
sort(num.begin(), num.end()); do{
result.push_back(num);
}while(next_permutation(num.begin(), num.end())); return result; }
};
最新文章
- T1加权像(T1 weighted image,T1WI)
- [No000024]鲜为人知的编程真相
- [JAVA] 一个可以编辑、编译、运行Java简单文件的记事本java实现
- 附加到iis进程调试时找不到w3wp.exe
- 【LeetCode】21. Merge Two Sorted Lists
- hdu 4081 最小生成树+树形dp
- intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
- VS2013以管理员身份使用
- 【多重背包模板】poj 1014
- druid查询
- Linux系列教程(二)——Linux系统安装(手把手学安装centos6.8)
- CommonJS,AMD,RequireJS的区别
- Linux下的 >;, >;>;, <;, ps, |, grep, /dev/null
- C语言第六周博客作业--数据类型
- Spring入门(一):创建Spring项目
- maven pom 属性介绍
- bootstrap的引用和注意事项
- vuex最简单的
- hibernate框架学习之持久化对象OID
- Hadoop-3.0.2 覆盖源代码生效