#include <algorithm> class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param num int整型vector * @return int整型vector<vector<>> */ vector<vector<int> > permute(vector<int>& num) { vector <vector <int>> ans; vector <int> a=num; while(prev_permutation(num.begin(), num.end())) { ans.push_back(num); } ans.push_back(a); while(next_permutation(a.begin(), a.end())) { ans.push_back(a); } return ans; } };