Problem. Given nums of distinct integers, return all possible orderings.
nums = [1, 2, 3] → [1,2,3] [1,3,2] [2,1,3] [2,3,1] [3,1,2] [3,2,1]
nums = [0, 1] → [0,1] [1,0]
There are n! orderings, each of length n, so O(n · n!) is the floor. It grows brutally: 10! = 3.6 million, 13! = 6 billion. Past n ≈ 10 you don't enumerate orderings, you sample or search them (Changes C and D).
ML context. Orderings appear as data shuffles (every epoch should see a fresh uniformly random order), curriculum orderings, the order of preprocessing steps, the order layers are assigned to devices, and permutation tests (shuffle the labels to see if a metric beats chance). Almost always you need a random permutation or a few specific ones, not all n!, and getting the random one exactly uniform has a classic pitfall.