types

package
v0.0.0-...-50b2653 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2021 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const SizeThreshold = 1000

单链表长度上限

Variables

This section is empty.

Functions

This section is empty.

Types

type ListNode

type ListNode struct {
	Val  int
	Next *ListNode
}

单链表节点

func NewList

func NewList(values ...int) *ListNode

创建新的单链表

func (*ListNode) Clone

func (l *ListNode) Clone() *ListNode

克隆单链表 如果链表有环,将引发错误

func (*ListNode) String

func (l *ListNode) String() string

打印单链表 如果链表有环,将引发错误

type TreeNode

type TreeNode struct {
	Val   int
	Left  *TreeNode
	Right *TreeNode
}

二叉树节点

func NewTree

func NewTree(values ...int) *TreeNode

创建新的二叉树 按照值的层序遍历创建树,小于 0 的值视为空节点,空节点将在下一层中被忽略

func (*TreeNode) Clone

func (tree *TreeNode) Clone() *TreeNode

克隆二叉树

func (*TreeNode) String

func (tree *TreeNode) String() string

打印二叉树

Jump to

Keyboard shortcuts

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