Time complexity: O(n²) due to list removal operations.
Space complexity: O(n) for the numbers list and result.
This avoids generating all n! permutations.
(Direct computation)
Time complexity: O(n²) due to list removal operations.
Space complexity: O(n) for the numbers list and result.
This avoids generating all n! permutations.