public: Solution(std::vector<int>& nums) { this->nums = nums; } /** Resets the array to its original configuration and return it. */ std::vector<int> reset(){ return nums; } /** Returns a random shuffling of the array. */ std::vector<int> shuffle(){ auto ret = std::vector<int>(nums); for(int i = 0; i < ret.size(); i++) { int index = rand() % (ret.size() - i); std::swap(ret[i], ret[i + index]); } return ret; } };
/** * Your Solution object will be instantiated and called as such: * Solution* obj = new Solution(nums); * vector<int> param_1 = obj->reset(); * vector<int> param_2 = obj->shuffle(); */