Math Fundamentals18 sections · 814 units
Open in Course

Permutations - Implementation

(Python solution)

Time complexity: O(n × n!). You generate n! permutations, each takes O(n) to copy.

Space complexity: O(n) for recursion depth and the used array.

This is the standard backtracking template for permutations.