您的位置:首页 > 其它

LeetCode - 31. Next Permutation

2017-03-05 17:26 375 查看
 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());
           return;
       }
   }
};
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: