您的位置:首页 > 其它

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: