solve the permutations with repeat num problem.