01 · Question
Given an array nums of distinct integers, return all possible permutations.
02 · Analysis
A level chooses the value at the next output position. Keep used indices and undo both the used flag and path append after recursion. With n distinct values, there are n! answers of length n: O(n*n!) time/output space, plus O(n) auxiliary space. Returning a shared path reference instead of a snapshot corrupts earlier results.