天天看點

LeetCode - 31. Next Permutation 31. Next Permutation Problem's Link

 ----------------------------------------------------------------------------

Mean: 

給定一個數列,求這個數列字典序的下一個排列.

analyse:

next_permutation函數的運用.

Time complexity: O(N)

view code

class Solution

{

public:

   void nextPermutation(vector<int>& nums)

   {

       if(next_permutation(nums.begin(),nums.end()))

           return;

       else

       {

           sort(nums.begin(),nums.end());

       }

   }

};

繼續閱讀