Implement generation of permutations containing duplicated chars by following wikipedia's solution.