One C++ sentence to solve the problem AC by using the STL algorithm


  • 0
    C

    use the STL algorithm ,we can solve the problem only one sentense.

    void nextPermutation(vector<int> &nums)
    {
        next_permutation(nums.begin(), nums.end());
    }
    

    next_permutation(first,last) in the <algorithm> head file,its defination is that:

    Rearranges the elements in the range [first,last) into the next lexicographically greater permutation.

    the cplusplus explantion


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.