Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
leetcode: finished #384
Browse files Browse the repository at this point in the history
  • Loading branch information
xqm32 committed Feb 18, 2024
1 parent faa3dfa commit aa17305
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions content/leetcode/2024/2.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,39 @@ title: 2024.2
draft: false
---

# 2024.2.18

```python
#
# @lc app=leetcode.cn id=384 lang=python3
#
# [384] 打乱数组
#

# @lc code=start
class Solution:
def __init__(self, nums: List[int]):
self.nums = nums
self.original = list(nums)

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

def shuffle(self) -> List[int]:
for i in range(len(self.nums)):
j = random.randint(i, len(self.nums) - 1)
self.nums[i], self.nums[j] = self.nums[j], self.nums[i]
return self.nums


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

# 2024.2.17

```python
Expand Down

0 comments on commit aa17305

Please sign in to comment.