Coding · Medium · Pro
Generate all subsets (power set) of an array
CodingRecursionBacktrackingSenior
Approach
- At each index, choose to include or exclude the element.
- Base case: index == length → add current path to result.
Java Solution
Java
public List<List<Integer>> subsets(int[] nums) {
List<Li…