Permutation of an array, with repetition, in Java

前端 未结 4 1086
名媛妹妹
名媛妹妹 2021-01-12 01:47

There are some similar questions on the site that have been of some help, but I can\'t quite nail down this problem, so I hope this is not repetitive.

This is a home

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-12 02:14

    I just had an idea. What if you added a hidden character (H for hidden) [A, B, C, H], then did all the fixed length permutations of it (you said you know how to do that). Then when you read it off, you stop at the hidden character, e.g. [B,A,H,C] would become (B,A).

    Hmm, the downside is that you would have to track which ones you created though [B,H,A,C] is the same as [B,H,C,A]

提交回复
热议问题