problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
leetcode::permutations::Solution类 参考

#include <leetcode.h>

静态 Public 成员函数

static vector< vector< int > > permute (vector< int > &nums)
 

详细描述

在文件 leetcode.h440 行定义.

成员函数说明

◆ permute()

vector< vector< int > > leetcode::permutations::Solution::permute ( vector< int > &  nums)
static

在文件 leetcode.cpp1000 行定义.

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);
1006 return ans;
1007 }
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);
1018 }
1019 }
1020 return ans;
1021 }
bool find(vector< unordered_set< int > > &g, int x, vector< bool > &st, vector< int > &match)
Definition: acwing.cpp:7522
static vector< vector< int > > permute(vector< int > &nums)
Definition: leetcode.cpp:1000

引用了 acwing::acwing861::find() , 以及 permute().

被这些函数引用 permute() , 以及 leetcode::permutations::TEST().


该类的文档由以下文件生成: