s4553711
11/9/2017 - 2:39 PM

384.cpp

class Solution {
    vector<int> nums;
public:
    Solution(vector<int> nums) {
        this->nums = nums;
    }
    
    /** Resets the array to its original configuration and return it. */
    vector<int> reset() {
        return nums;
    }
    
    /** Returns a random shuffling of the array. */
    vector<int> shuffle() {
        vector<int> results(nums);
        for(int i = 0; i < results.size(); i++) {
            int pos = rand()%(results.size() - i);
            swap(results[pos + i], results[i]);
        }
        return results;
    }
};