problem0384

package
v0.0.0-...-db5e768 Latest Latest
Warning

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

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

README

384. Shuffle an Array

题目

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

解题思路

见程序注释

100

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
}

Solution 是答案

func Constructor

func Constructor(nums []int) Solution

Constructor 构建 Solution

func (Solution) Reset

func (s Solution) Reset() []int

Reset the array to its original configuration and return it.

func (Solution) Shuffle

func (s Solution) Shuffle() []int

Shuffle returns a random shuffling of the array.

Jump to

Keyboard shortcuts

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