day337

package
v0.0.0-...-36687a4 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SinglyLL

type SinglyLL struct {
	Val  interface{}
	Next *SinglyLL
}

SinglyLL is a singly linked list of any kind of value. Type management falls to the user.

func FastShuffle

func FastShuffle(head *SinglyLL) *SinglyLL

FastShuffle uniformly shuffles the singly linked list in O(N) time and O(N) space. Technically, O(2N) space. First N is for slice of values, second N is for new Linked List (not done in-place and doesn't mutate input linked list).

func MemoryOptimizedShuffle

func MemoryOptimizedShuffle(head *SinglyLL) *SinglyLL

MemoryOptimizedShuffle uniformly shuffles the singly linked list in O(N^2) time and O(1) space.

Jump to

Keyboard shortcuts

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