以所有可能的变化将一个集合除以其他集合
假设我们有一个集合 S = [a,b,c,d,e,f]。我们有一个集合 N = [1,2,3]。
我们怎样才能以所有可能的组合将 S 的元素分配给 N 的元素?
所需的结果将包含如下内容:
- [1,[a]], [2,[b,c]], [3,[d,e,f]]。
- [1,[a]],[2,[b,c,d]],[3,[e,f]]。
- 等等。
这是一个 powerset 生成问题还是其他问题?如何求其复杂度和空间复杂度?
我怎样才能生成这些子集?
Imagine we have a set S = [a,b,c,d,e,f]. And we have a set N = [1,2,3].
How can we assign elements of S to elements of N in all possible combinations?
The desired result will hold something like this:
- [1,[a]], [2,[b,c]], [3,[d,e,f]].
- [1,[a]], [2,[b,c,d]],[3,[e,f]].
- etc.
Is it a powerset generation problem or anything else? How can I find its complexity and space complexity?
How can I generate those subsets?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个问题与发电机组的发电有关。你将得到 |N|^|S|可能的映射。
This problem is related to the powerset generation. You will get |N|^|S| possible mappings.