Friday, April 15, 2016

Lintcode 198 - Permutation Index II

Given a permutation which may contain repeated numbers, find its index in all the permutations of these numbers, which are ordered in lexicographical order. The index begins at 1.
Example
Given the permutation [1, 4, 2, 2], return 3.