#![allow(dead_code, unused, unused_variables)] fn main() {} /** * Your Solution object will be instantiated and called as such: * let obj = Solution::new(nums); * let ret_1: Vec = obj.reset(); * let ret_2: Vec = obj.shuffle(); */ struct Solution { nums: Vec, } /** * `&self` means the method takes an immutable reference. * If you need a mutable reference, change it to `&mut self` instead. */ impl Solution { fn new(nums: Vec) -> Self { Self { nums } } /** Resets the array to its original configuration and return it. */ fn reset(&self) -> Vec { self.nums.clone() } /** Returns a random shuffling of the array. */ fn shuffle(&self) -> Vec { use rand::Rng; let mut rng = rand::thread_rng(); let mut v = self.nums.clone(); for i in 0..self.nums.len() { v.swap(rng.gen_range(0..self.nums.len()), i); } v } }