Permutation Index(LintCode 197):

Problem