problemscpp
A collection of my answers to algorithm problems in c++.
| 函数
leetcode::permutations 命名空间参考

LeetCode 46. 全排列 更多...

class  Solution
 

函数

 TEST (permutations, case1)
 
 TEST (permutations, case2)
 
 TEST (permutations, case3)
 

详细描述

LeetCode 46. 全排列

函数说明

◆ TEST() [1/3]

leetcode::permutations::TEST ( permutations  ,
case1   
)

在文件 leetcode_test.cpp601 行定义.

601 {
602 int input[] = {1};
603 auto vec = vector(begin(input), end(input));
604 auto ans = vector<vector<int>>();
605 auto ans1 = vector<int>();
606 ans1.push_back(1);
607 ans.push_back(ans1);
608 ASSERT_EQ(ans, Solution::permute(vec));
609 }
int vec[100010]
Definition: pat.cpp:5095

引用了 leetcode::permutations::Solution::permute() , 以及 pat::a::a7_2::vec.

◆ TEST() [2/3]

leetcode::permutations::TEST ( permutations  ,
case2   
)

在文件 leetcode_test.cpp611 行定义.

611 {
612 int input[] = {0, 1};
613 auto vec = vector(begin(input), end(input));
614 auto ans = vector<vector<int>>();
615 auto ans1 = vector<int>();
616 ans1.push_back(0);
617 ans1.push_back(1);
618 ans.push_back(ans1);
619 auto ans2 = vector<int>();
620 ans2.push_back(1);
621 ans2.push_back(0);
622 ans.push_back(ans2);
623 ASSERT_EQ(ans, Solution::permute(vec));
624 }

引用了 leetcode::permutations::Solution::permute() , 以及 pat::a::a7_2::vec.

◆ TEST() [3/3]

leetcode::permutations::TEST ( permutations  ,
case3   
)

在文件 leetcode_test.cpp626 行定义.

626 {
627 int input[] = {1, 2, 3};
628 auto vec = vector(begin(input), end(input));
629 auto ans = vector<vector<int>>();
630 int outputs[6][3] = {{1, 2, 3}, {1, 3, 2}, {2, 1, 3}, {2, 3, 1}, {3, 1, 2}, {3, 2, 1}};
631 for(auto &output: outputs) {
632 ans.emplace_back(begin(output), end(output));
633 }
634 ASSERT_EQ(ans, Solution::permute(vec));
635 }

引用了 leetcode::permutations::Solution::permute() , 以及 pat::a::a7_2::vec.