Enumerate the complete power set of distinct integers with choose-or-skip backtracking. Explain deterministic output ordering, copying mutable state, completeness, and exponential output size.
Given an array of distinct integers, return its complete power set: every subset, including the empty subset, exactly once. The report identifies the standard Subsets problem and explicitly permits ordinary enumeration without further optimization.
### Constraints and Clarifications
All input values are unique. No numerical size bounds were reported. Subset ordering is not semantically important. For a deterministic practice representation, retain input order within each subset and enumerate decisions in input-index order, visiting exclusion before inclusion. This is output normalization for one complete set, not a request to choose one arbitrary valid subset. Empty input has the single subset [].
### Example
For [1,2,3], the normalized enumeration is [[],[3],[2],[2,3],[1],[1,3],[1,2],[1,2,3]]. Other orderings describe the same power set, but the practice convention fixes serialization.
### What a Strong Answer Covers
Use choose-or-skip recursion or an equivalent enumeration, copy each completed subset, and explain O(n*2^n) output-sensitive time with O(n) working space excluding output.
### Follow-up Questions
- Why must the current subset be copied when adding it to the result?
- What changes if the input contains duplicate values?
Overview: Enumerate the complete power set of distinct integers with choose-or-skip backtracking. Explain deterministic output ordering, copying mutable state, completeness, and exponential output size.
Given an array of distinct integers, return its complete power set: every subset, including the empty subset, exactly once. The report identifies the standard Subsets problem and explicitly permits ordinary enumeration without further optimization.
Constraints and Clarifications
All input values are unique. No numerical size bounds were reported. Subset ordering is not semantically important. For a deterministic practice representation, retain input order within each subset and enumerate decisions in input-index order, visiting exclusion before inclusion. This is output normalization for one complete set, not a request to choose one arbitrary valid subset. Empty input has the single subset [].
Example
For [1,2,3], the normalized enumeration is [[],[3],[2],[2,3],[1],[1,3],[1,2],[1,2,3]]. Other orderings describe the same power set, but the practice convention fixes serialization.
What a Strong Answer Covers Guidance
Use choose-or-skip recursion or an equivalent enumeration, copy each completed subset, and explain O(n*2^n) output-sensitive time with O(n) working space excluding output.
Follow-up Questions Guidance
Why must the current subset be copied when adding it to the result?
What changes if the input contains duplicate values?