Acwing #51(数字排列)

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/i_meteor_shower/article/details/100943177

点击跳转题目


bool next_permutation(begin, end);
对数组按照字典序升序排列一次,如原数组是最大字典序,则返回false。

class Solution {
public:
    vector<vector<int>> permutation(vector<int>& nums) {
        vector<vector<int>> res;
        do{
            res.push_back(nums);
        }while(next_permutation(nums.begin(), nums.end()));
        return res;
    }
};

猜你喜欢

转载自blog.csdn.net/i_meteor_shower/article/details/100943177
今日推荐