解题思路:
直接利用random的shuffle函数即可。
具体代码如下:
import random
class Solution:
def __init__(self, nums: List[int]):
self.original = nums[:]
self.data = nums
def reset(self) -> List[int]:
"""
Resets the array to its original configuration and return it.
"""
return self.original
def shuffle(self) -> List[int]:
"""
Returns a random shuffling of the array.
"""
random.shuffle(self.data)
return self.data
# Your Solution object will be instantiated and called as such:
# obj = Solution(nums)
# param_1 = obj.reset()
# param_2 = obj.shuffle()