3109. Find the Index of Permutation
ArrayBinary SearchDivide and ConquerBinary Indexed TreeSegment TreeMerge SortOrdered Set
Hints
Hint 1
If
perm[0] is x, there are at least (x - 1) * (n - 1)! permutations before perm. (All the ones starting with numbers less than x)Hint 2
Can you find out what happens for
perm[1] onwards?Hint 3
Think about the count of the numbers that can be in place of
perm[i] and come before it.Preparing judge…