class Solution { public: Solution(vector& nums) : m_original(nums) {} vector reset() { return m_original; } vector shuffle() { std::vector shuffled = m_original; for (size_t i = 0; i < shuffled.size(); ++i) { const size_t j = random() % shuffled.size(); std::swap(shuffled[i], shuffled[j]); } return shuffled; } private: size_t random() { uint64_t x = m_random; // xorshift64 x ^= x << 13; x ^= x >> 7; x ^= x << 17; m_random = x; return x; } std::vector m_original; std::uint64_t m_random = 16240738485554559101; }; /** * Your Solution object will be instantiated and called as such: * Solution* obj = new Solution(nums); * vector param_1 = obj->reset(); * vector param_2 = obj->shuffle(); */