HTMLify

LeetCode - Shuffle an Array - Python
Views: 37 | Author: abh
from random import shuffle

class Solution:

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

    def reset(self) -> List[int]:
        self.list = self.orgi.copy()
        return self.list

    def shuffle(self) -> List[int]:
        shuffle(self.list)
        return self.list
        

# Your Solution object will be instantiated and called as such:
# obj = Solution(nums)
# param_1 = obj.reset()
# param_2 = obj.shuffle()

Comments