Dashboard Temp Share Shortlinks Frames API

HTMLify

LeetCode - Shuffle an Array - Python
Views: 327 | Author: abh
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
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()