Solution

package
v0.0.0-...-adc727d Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2020 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LoopQueue

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

func Constructor

func Constructor(capacity int) *LoopQueue

func (*LoopQueue) Dequeue

func (this *LoopQueue) Dequeue() (e interface{})

获得队列头部元素

func (*LoopQueue) Enqueue

func (this *LoopQueue) Enqueue(e interface{})

入队

func (*LoopQueue) GetCapacity

func (this *LoopQueue) GetCapacity() int

func (*LoopQueue) GetFront

func (this *LoopQueue) GetFront() interface{}

查看队列头部元素

func (*LoopQueue) GetSize

func (this *LoopQueue) GetSize() int

func (*LoopQueue) IsEmpty

func (this *LoopQueue) IsEmpty() bool

type Pair

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

type Queue

type Queue interface {
	GetSize() int
	IsEmpty() bool
	Enqueue(interface{})
	Dequeue() interface{}
	GetFront() interface{}
}

在这一版LoopQueue的实现中,我们将不浪费那1个空间:)

type TreeNode

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

/ Leetcode 102. Binary Tree Level Order Traversal / https://leetcode.com/problems/binary-tree-level-order-traversal/description/ / 二叉树的层序遍历 / / 二叉树的层序遍历是一个典型的可以借助队列解决的问题。 / 该代码主要用于使用Leetcode上的问题测试我们的LoopQueue。 / 对于二叉树的层序遍历,这个课程后续会讲到。 / 届时,同学们也可以再回头看这个代码。 / 不过到时,大家应该已经学会自己编写二叉树的层序遍历啦:)

Jump to

Keyboard shortcuts

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