Given an integer array nums, design an algorithm to randomly shuffle the array. All permutations of the array should be equally likely as a result of the shuffling.

Implement the Solution class:


	Solution(int[] nums) Initializes the object with the integer array nums.
	int[] reset() Resets the array to its original configuration and returns it.
	int[] shuffle() Returns a random shuffling of the array.


&nbsp;
Example 1:

Input
["Solution", "shuffle", "reset", "shuffle"]
[[[1, 2, 3]], [], [], []]
Output
[null, [3, 1, 2], [1, 2, 3], [1, 3, 2]]

Explanation
Solution solution = new Solution([1, 2, 3]);
solution.shuffle();    // Shuffle the array [1,2,3] and return its result.
                       // Any permutation of [1,2,3] must be equally likely to be returned.
                       // Example: return [3, 1, 2]
solution.reset();      // Resets the array back to its original configuration [1,2,3]. Return [1, 2, 3]
solution.shuffle();    // Returns the random shuffling of array [1,2,3]. Example: return [1, 3, 2]



&nbsp;
Constraints:


	1 &lt;= nums.length &lt;= 50
	-106 &lt;= nums[i] &lt;= 106
	All the elements of nums are unique.
	At most 104 calls in total will be made to reset and shuffle.


import random 

class Solution:

    def __init__(self, nums: List[int]):
        self.nums = nums

    def reset(self) -> List[int]:  
        return self.nums

    def shuffle(self) -> List[int]:
        shuffled_array = self.nums.copy()
        # randomly generates the idx of the element that'll be the ith element of the array 
        for i in range(len(self.nums) - 1, 0, -1):
            idx = random.randint(0, i)
            shuffled_array[i], shuffled_array[idx] = shuffled_array[idx], shuffled_array[i]
        return shuffled_array
class Solution {

    int a[];
    int b[];
    public Solution(int[] nums) {
        a=nums.clone();
        b=nums.clone();
    }

    public int[] reset() {
        a=b.clone();
        return a;
    }

    public int[] shuffle() {

        for(int i=0;i<a.length;i++){
            int ren=(int)(Math.random()*a.length);
            int temp= a[ren];
             a[ren]=a[i];
            a[i]=temp;
        }
        return a;
    }
}

/**
 * Your Solution object will be instantiated and called as such:
 * Solution obj = new Solution(nums);
 * int[] param_1 = obj.reset();
 * int[] param_2 = obj.shuffle();
 */
class Solution {
public:
    vector<int> ans;
    vector<int> res;
    Solution(vector<int>& nums) {
        ans=nums;
        res=nums;
    }
    
    vector<int> reset() {
        return res;
    }
    
    vector<int> shuffle() {
        next_permutation(ans.begin(),ans.end());
        return ans;
    }
};
var Solution = function(nums) {
    this.nums = nums;
    this.resetArray = [...nums];
};

Solution.prototype.reset = function() {
    return this.resetArray;
};

Solution.prototype.shuffle = function() {

    const n = this.nums.length;
    const numsArray = this.nums;

    for (let i = 0; i < n; i++) {
        const j = Math.floor(Math.random() * (n - i)) + i;
        const tmp = numsArray[i];
        numsArray[i] = numsArray[j];
        numsArray[j] = tmp;
    }

    return numsArray;
};
Shuffle an Array