Leetcode Next Permutation
2015-07-25 12:40
288 查看
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order).The replacement must be in-place, do not allocate extra memory.Here are some examples. Inputs are in the left-hand column and its corresponding outputs are in the right-hand column.
1,2,3→
1,3,2
3,2,1→
1,2,3
1,1,5→
1,5,1
class Solution { public: void nextPermutation(vector<int>& nums) { next_permutation(nums.begin(),nums.end()); } };
相关文章推荐
- hdu 4126
- ------------------------------------------------------------
- 一个漂亮的PHP验证码
- Python实现简单的代理服务器
- 微软官方Win10系统U盘谍照曝光 含32位/64位双重版本
- 己亥岁
- HTML之标签
- 深入了解View(三)—— draw绘制流程分析
- 使用abel533大神的mybatis分页插件总结
- 一个漂亮的php验证码类(分享)
- android图片处理之图像模糊
- Codeforces Beta Round #93 (Div. 1 Only) D. Fibonacci Sums
- unity灯光Lightmapping、LightProbes
- DNS子域授权及视图view功能的应用
- 解决Word文档邮件合并产生的超长小数位
- 程序员笔试面试系列-网络与通信知识点
- Android---webview的用法
- tomcat_配置jdbc(小例)
- zoj2099
- Windows无法连接到选定网络,网络可能不在区域中。请刷新可用网络的列表,重新尝试