其他分享
首页 > 其他分享> > [剑指offer]JT27---字符串的排列(直接调用函数偷个懒)

[剑指offer]JT27---字符串的排列(直接调用函数偷个懒)

作者:互联网

剑指offer第二十七题

题目如下

在这里插入图片描述

思路与代码

全排列的实现可以用深搜就好了,一个一个的填进去
这里直接用函数

class Solution {
public:
    vector<string> Permutation(string str) {
        sort(str.begin(),str.end());
        vector<string> ans;
        do{
            ans.push_back(str);
        }while(next_permutation(str.begin(),str.end()));
        return ans;
    }
};

在这里插入图片描述

标签:begin,end,offer,偷个,调用函数,vector,str,ans
来源: https://blog.csdn.net/qq_42136832/article/details/114795332