1.1 数据结构

数据结构 #

常用的数据结构 #


数据结构定义(源码) #

#

stack := make([]int, 0)

// push 入栈
stack = append(stack, 3)

// pop 出栈
v := stack[len(stack) - 1]
stack = stack[: len(stack) - 1]

// 判断栈为空
if len(stack) == 0 {

}

队列 #

queue := make([]int, 0)

// enqueue 入队
queue = append(queue, 5)

// dequeue 出队
v := queue[0]
queue = queue[1:]

// 判断长度为 0
if len(queue) == 0 {

}

链表 (Linked List) #

单向链表 节点 #

# Definition for singly-linked list.
class ListNode(object):
    def __init__(self, val):
        self.val = val
        self.next = None
# Definition for singly-linked list.
class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None

双向链表 节点 #

# Definition for doubly-linked list.
class ListNode(object):
    def __init__(self, val):
        self.val = val
        self.pre = None
        self.next = None
# Definition for doubly-linked list.
class ListNode:
    def __init__(self, val):
        self.val = val
        self.pre = None
        self.next = None

#

# Definition for a binary tree node
class TreeNode(object) {
    def __init__(self, val):
        self.val = val
        self.left = None
        self.right = None
}
# Definition for a binary tree node
class TreeNode {
    def __init__(self, val):
        self.val = val
        self.left = None
        self.right = None
}

数据结构列表 #

类型 #

抽象类型 #

数组 #

#

Linked data structure

#

#


本文访问量

本站总访问量

本站总访客数