@@ -0,0 +1,1063 @@
+package leetcode;%0A%0Aimport java.util.Arrays;%0Aimport java.util.Random;%0A%0A/**%0A * https://leetcode.com/problems/shuffle-an-array/%0A */%0Apublic class Problem384 %7B%0A    public static class Solution %7B%0A        private final int%5B%5D nums;%0A        private final int%5B%5D original;%0A        private final Random random = new Random();%0A%0A        public Solution(int%5B%5D nums) %7B%0A            this.nums = nums;%0A            original = Arrays.copyOf(nums, nums.length);%0A        %7D%0A%0A        /** Resets the array to its original configuration and return it. */%0A        public int%5B%5D reset() %7B%0A            return original;%0A        %7D%0A%0A        /** Returns a random shuffling of the array. */%0A        public int%5B%5D shuffle() %7B%0A            // Knuth's shuffle%0A            for (int i = 0; i %3C nums.length; i++) %7B%0A                int j = random.nextInt(i + 1);%0A                swap(nums, i, j);%0A            %7D%0A            return nums;%0A        %7D%0A%0A        private void swap(int%5B%5D nums, int i, int j) %7B%0A            int tmp = nums%5Bi%5D;%0A            nums%5Bi%5D = nums%5Bj%5D;%0A            nums%5Bj%5D = tmp;%0A        %7D%0A    %7D%0A%7D%0A

Solve problem 384