Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
与えられた:
{1,2,3}
期待される結果:
{1,2,3}, {1,2},{1,3},{2,3}, {1},{2},{3}
したがって、基本的にリスト内のすべての可能な組み合わせが必要です(ただし、すべての可能な組み合わせを含む-すべての要素が削除された場合)。
私が言いたいことを理解していただければ幸いです;)
質問: これを実現するアルゴリズムはどれですか?
パワーセットアルゴリズムが必要です。
Rosetta Codeにはいくつかの例があります。