leetcode

package
v0.0.0-...-0e3bca9 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2019 License: Unlicense Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ListNode

type ListNode struct {
	Val  int
	Next *ListNode
}

ListNode is a node of a linked list.

type Solution

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

Solution is the solution for the reservoir sampling algorithm.

func Constructor

func Constructor(head *ListNode) Solution

Constructor accepts a head node of a linked list. Note that the head is guaranteed to be not null, so it contains at least one node.

func (*Solution) GetRandom

func (s *Solution) GetRandom() int

GetRandom returns a random node's value.

Jump to

Keyboard shortcuts

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