1import random234class Solution:56def __init__(self, nums: List[int]):7self.nums = nums89def reset(self) -> List[int]:10return self.nums1112def shuffle(self) -> List[int]:13shuffled_array = self.nums.copy()14# randomly generates the idx of the element that'll be the ith element of the array15for i in range(len(self.nums) - 1, 0, -1):16idx = random.randint(0, i)17shuffled_array[i], shuffled_array[idx] = (18shuffled_array[idx],19shuffled_array[i],20)21return shuffled_array