#include <leetcode.h>
|
static vector< vector< int > > | permute (vector< int > &nums) |
|
◆ permute()
vector< vector< int > > leetcode::permutations::Solution::permute |
( |
vector< int > & |
nums | ) |
|
|
static |
在文件 leetcode.cpp 第 1000 行定义.
1001 auto ans = vector<vector<int>>();
1002 if(nums.size() == 1) {
1003 auto next_ans = vector<int>();
1004 next_ans.push_back(nums[0]);
1005 ans.push_back(next_ans);
1008 for(
auto num: nums) {
1009 auto next = vector(nums);
1010 next.erase(
find(next.begin(), next.end(), num));
1011 auto next_permutations =
permute(next);
1012 auto new_ans = vector<int>();
1013 new_ans.push_back(num);
1014 for(
auto next_permutation: next_permutations) {
1015 auto next_ans = vector(new_ans);
1016 next_ans.insert(next_ans.end(), next_permutation.begin(), next_permutation.end());
1017 ans.push_back(next_ans);
bool find(vector< unordered_set< int > > &g, int x, vector< bool > &st, vector< int > &match)
static vector< vector< int > > permute(vector< int > &nums)
引用了 acwing::acwing861::find() , 以及 permute().
被这些函数引用 permute() , 以及 leetcode::permutations::TEST().
该类的文档由以下文件生成: