Home
Log in
DescriptionSubmissionsSolution
DescriptionSubmissionsSolution
Loading...

Log in to run or submit

nums =

Codey

Practise coding problems, test your solutions and track your progress.

Explore

  • Problems
  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

© 2026 Codey. Personal learning project.

Solution
Updated: 2026-02-23

Idea

Each element is either included or excluded.

Approach

Backtrack over index i:

  • Recurse without taking nums[i].
  • Take it, recurse, then undo.

Why it works

Binary choice per element produces all 2^n subsets exactly once.

Code
Loading...
Complexity
Time: O(n*2^n)
Space: O(n)
Solution
Updated: 2026-02-23

Idea

Each element is either included or excluded.

Approach

Backtrack over index i:

  • Recurse without taking nums[i].
  • Take it, recurse, then undo.

Why it works

Binary choice per element produces all 2^n subsets exactly once.

Code
Loading...
Complexity
Time: O(n*2^n)
Space: O(n)