by thethirdone · 1y ago · 0 comments
If the requirements are softer than "n random permutations", there might be a lot of potential solutions. It is very easy to come up with "n permutations" if you have no requirements on the randomness of them. Pick the lowest `k` such that `n < k!`, permute the first k elements leaving the rest in place, and now you have n distinct permutations storeable in `O(log(n)` (still not O(1) but close).
I know this is not really your point, but misusing `O(1)` is a huge pet peeve of mine.
Those sorts of applications would tend to not work well with a solution leaving most elements in the same place or with the same relative ordering.