linked_list_random_node

package
v0.0.0-...-a70e5fa Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package linked_list_random_node https://leetcode-cn.com/problems/linked-list-random-node/

382. 链表随机节点

给定一个单链表,随机选择链表的一个节点,并返回相应的节点值。保证每个节点被选的概率一样。

进阶:

如果链表十分大且长度未知,如何解决这个问题?你能否使用常数级空间复杂度实现?

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
}

type SolutionS1

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

func ConstructorS1

func ConstructorS1(head *ListNode) SolutionS1

func (*SolutionS1) GetRandom

func (this *SolutionS1) GetRandom() int

Jump to

Keyboard shortcuts

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