shuffleAnArray

package
v0.0.0-...-2b489ef Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: MIT Imports: 1 Imported by: 0

README

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();

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Solution

type Solution struct {
	// contains filtered or unexported fields
}

Store the origin and shuffed

func Constructor

func Constructor(nums []int) Solution

Construct a solution

func (*Solution) Reset

func (Solution *Solution) Reset() []int

Return the original array

func (*Solution) Shuffle

func (Solution *Solution) Shuffle() []int

Shuffle and return the shuffed array

Jump to

Keyboard shortcuts

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