shuffle_an_array

package
v1.4.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2019 License: MIT Imports: 0 Imported by: 0

README

< Previous                  Next >

384. Shuffle an Array (Medium)

Shuffle a set of numbers without duplicates.

Example:

// Init an array with set 1, 2, and 3.
int[] nums = {1,2,3};
Solution solution = new Solution(nums);

// Shuffle the array [1,2,3] and return its result. Any permutation of [1,2,3] must equally likely to be returned. solution.shuffle();

// Resets the array back to its original configuration [1,2,3]. solution.reset();

// Returns the random shuffling of array [1,2,3]. solution.shuffle();

Hints

Hint 1 The solution expects that we always use the original array to shuffle() else some of the test cases fail. (Credits; @snehasingh31)

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL