ecneuqeSnoitatumreP.60
2016-02-02 00:13
288 查看
problem:https://leetcode.com/problems/permutation-sequence/
tips:
求余,除法求index。
注意数组从0开始,以及index的特性,如n/n = 1,但是其实index应该为0。所以计算公式为index = (n-1)/ n。
求余比乘法快。
(k-1)%n+1 = k - (k-1)/n*n
tips:
求余,除法求index。
注意数组从0开始,以及index的特性,如n/n = 1,但是其实index应该为0。所以计算公式为index = (n-1)/ n。
求余比乘法快。
(k-1)%n+1 = k - (k-1)/n*n
相关文章推荐
- DOS中的乱码以及编码的问题
- static应用
- SolrCloud中的文件与Collection管理
- cocos2d-x CheckBox的使用
- 使用 JavaScript 控制 HTML5 视频播放器
- 素数筛选
- 算法时间复杂度的计算 [整理]
- Android断点下载实现
- 继承、组合和接口用法——策略模式复习总结
- HDU 1319 Prime Cuts(打表)
- Codeforces Round #341 (Div. 2) B
- Android学习笔记—Service(1、start启动)
- leetcode之Serialize and Deserialize Binary Tree
- HelloWorld二三事:创建项目、目录结构、DDMS/ADB/Logcat工具、app怎么运行的
- 编程题
- 多线程总结下
- POJ2492-A Bug's Life-并查集扩展应用
- MongoDB_条件操作符
- 多线程总结上
- solr 为单独的core导入jar