ecneuqeSnoitatumreP.60

来源:互联网 发布:python 判断进程状态 编辑:程序博客网 时间:2024/06/09 22:53

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

0 0