Design a class Shuffler that holds an array and can shuffle it or return it to its original order.
new Shuffler(nums, rng) keeps its own copy of nums. rng returns numbers in [0, 1)reset() returns the original order as an arrayshuffle() returns a uniformly random order of the elements: every order has probability 1/n!, and one call does not depend on the one before- Neither method may hand out the array it stores. If a caller changes a returned array, later calls must still behave correctly
- Changing the array that was passed to the constructor, after the constructor ran, must not change what
reset() returns - Shuffle with Fisher-Yates from the back, one draw per step, so tests can script the generator: for
i from n - 1 down to 1, set j = Math.floor(rng() * (i + 1)) and swap positions i and j