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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MyLinkedList

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

MyLinkedList is my implementation of the linked list.

func Constructor

func Constructor() MyLinkedList

Constructor initialize your data structure here.

func (*MyLinkedList) AddAtHead

func (l *MyLinkedList) AddAtHead(val int)

AddAtHead add a node of value val before the first element of the linked list. After the insertion, the new node will be the first node of the linked list.

func (*MyLinkedList) AddAtIndex

func (l *MyLinkedList) AddAtIndex(index int, val int)

AddAtIndex add a node of value val before the index-th node in the linked list. If index equals to the length of linked list, the node will be appended to the end of linked list. If index is greater than the length, the node will not be inserted.

func (*MyLinkedList) AddAtTail

func (l *MyLinkedList) AddAtTail(val int)

AddAtTail append a node of value val to the last element of the linked list.

func (*MyLinkedList) DeleteAtIndex

func (l *MyLinkedList) DeleteAtIndex(index int)

DeleteAtIndex delete the index-th node in the linked list, if the index is valid.

func (*MyLinkedList) Get

func (l *MyLinkedList) Get(index int) int

Get get the value of the index-th node in the linked list. If the index is invalid, return -1.

Jump to

Keyboard shortcuts

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