Friday, August 7, 2015

MJ [2]

Questions: Similar to LeetCode Permutation Sequence [1] except the numbers in nums are not unique. In Test, there are 4 numbers whose permutations are in increasing order, find the sequence number (1-based) of one of its permutation in the sequence. Eg., if nums=[2 1 2 3] it should return 4; if nums=[3 1 2 2] it should return 10.

Test:
 1 2 2 3---1
 1 2 3 2---2
 1 3 2 2---3
 2 1 2 3---4
 2 1 3 2---5
 2 2 1 3---6
 2 2 3 1---7
 2 3 1 2---8
 2 3 2 1---9
 3 1 2 2---10
 3 2 1 2---11
 3 2 2 1---12

============ =====================


Ref
[1] https://leetcode.com/problems/permutation-sequence/
[2] http://www.mitbbs.com/article_t/JobHunting/33021689.html
[3] http://www.mitbbs.com/article_t1/JobHunting/32952623_0_1.html
Zenefits MJ, replace numbers with chars.

No comments:

Post a Comment