day104

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: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsPalindromeDoublyLL

func IsPalindromeDoublyLL(head *DoublyLL) bool

IsPalindromeDoublyLL answers the question "is this list a palindrome?". Runs on a doubly linked list. Runs in O(N) time and O(1) extra space.

func IsPalindromeSinglyLLReverse

func IsPalindromeSinglyLLReverse(head *SinglyLL) bool

IsPalindromeSinglyLLReverse answers the question "is this list a palindrome?". Runs on a singly linked list. Runs in O(N) time and O(1) space. NOTE: This modifies the linked list during execution, but restores it after completion.

func IsPalindromeSinglyLLStack

func IsPalindromeSinglyLLStack(head *SinglyLL) bool

IsPalindromeSinglyLLStack answers the question "is this list a palindrome?". Runs on a singly linked list. Runs in O(N) time and O(N) space.

Types

type DoublyLL

type DoublyLL struct {
	Value      int
	Prev, Next *DoublyLL
}

DoublyLL is a doubly linked list.

type SinglyLL

type SinglyLL struct {
	Value int
	Next  *SinglyLL
}

SinglyLL is a singly linked list.

func ReverseSinglyLL

func ReverseSinglyLL(head *SinglyLL) *SinglyLL

ReverseSinglyLL reverses a singly linked list in O(1) space and O(N) time.

Jump to

Keyboard shortcuts

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