Given a collection of numbers, return all possible permutations.
For example,[1,2,3] have
the following permutations:
[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2],
and [3,2,1].
思路:假设有集合[1,2,3],来一个4,则有集合[4,1,2,3]、[1,4,2,3]、[1,2,4,3]、[1,2,3,4]。故code如下:
class Solution {
public:
vector<vector<int> > permute(vector<int> &num) {
vector<vector<int> > aa,tmp;
vector<int> a;
aa.clear();
if(num.e......
阅读全文