Time complexity: O(n × n!). Sorting is O(n log n), then you generate unique permutations.
Space complexity: O(n) for recursion and used array.
The key: sorting + pruning condition eliminates duplicates cleanly.
(Duplicate pruning)
Time complexity: O(n × n!). Sorting is O(n log n), then you generate unique permutations.
Space complexity: O(n) for recursion and used array.
The key: sorting + pruning condition eliminates duplicates cleanly.