#include <leetcode.h>
|
| Solution (vector< int > &nums) |
| Initializes the object with the integer array nums. 更多...
|
|
vector< int > | reset () |
| Resets the array to its original configuration and returns it. 更多...
|
|
vector< int > | shuffle () const |
| Returns a random shuffling of the array. 更多...
|
|
◆ Solution()
leetcode::shuffle_an_array::Solution::Solution |
( |
vector< int > & |
nums | ) |
|
|
explicit |
Initializes the object with the integer array nums.
在文件 leetcode.cpp 第 6158 行定义.
6159 :
nums(
nums) { srand(time(
nullptr)); }
◆ reset()
vector< int > leetcode::shuffle_an_array::Solution::reset |
( |
| ) |
|
Resets the array to its original configuration and returns it.
在文件 leetcode.cpp 第 6145 行定义.
引用了 nums.
◆ shuffle()
vector< int > leetcode::shuffle_an_array::Solution::shuffle |
( |
| ) |
const |
Returns a random shuffling of the array.
在文件 leetcode.cpp 第 6147 行定义.
6149 vector<int> cpy =
nums;
6150 while(!cpy.empty()) {
6151 const int idx = rand() % cpy.size();
6152 ans.emplace_back(cpy[idx]);
6153 cpy.erase(cpy.begin() + idx);
引用了 nums.
◆ nums
vector<int> leetcode::shuffle_an_array::Solution::nums |
|
private |
该类的文档由以下文件生成: