Shuffle an Array
Shuffle an array randomly with all permutations as equally likely.
Statement
Given an integer array nums
, write an algorithm to shuffle the array randomly. All permutations of the array should be equally likely.
Implement three functions of the Solution
class:
- Initializes the object with the integer array
nums
. - Resets the array to its original configuration and returns it.
- Returns a random shuffling of the array.
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.