2025-08-24 16:38:13 +0000 UTC
Shuffle an Array
Categories:
Links
Code
class Solution:
def __init__(self, nums: List[int]):
self._orig = nums
self._cur = nums.copy()
def reset(self) -> List[int]:
return self._orig
def shuffle(self) -> List[int]:
return random.sample(self._orig, k=len(self._orig))
# Your Solution object will be instantiated and called as such:
# obj = Solution(nums)
# param_1 = obj.reset()
# param_2 = obj.shuffle()