code

package
v0.0.0-...-7e26a5e Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Num01MethodOne

func Num01MethodOne(target int, arr [][]int) bool

从右上角逐渐逼近

func Num01MethodTwo

func Num01MethodTwo(target int, arr [][]int) bool

因为是递增数组,可以使用二分查找

func Num02MethodOne

func Num02MethodOne(str string) string

func Num03MethodOne

func Num03MethodOne(node *ds.LinkNode) *ds.LinkNode

快慢指针

func Num03MethodTwo

func Num03MethodTwo(node *ds.LinkNode) *ds.LinkNode

递归

func Num04MethodOne

func Num04MethodOne(preOrder, midOrder []int) (root *ds.BTree)

func Num06MethodOne

func Num06MethodOne(arr []int) int

func Num07MethodOne

func Num07MethodOne(num int) int

func Num07MethodTwo

func Num07MethodTwo(num int) int

func Num08MethodOne

func Num08MethodOne(num int) int

func Num08MethodTwo

func Num08MethodTwo(num int) int

func Num09MethodOne

func Num09MethodOne(num int) int

func Num09MethodTwo

func Num09MethodTwo(num int) int

func Num10MethodOne

func Num10MethodOne(num int) int

func Num10MethodTwo

func Num10MethodTwo(num int) int

func Num11MethodOne

func Num11MethodOne(num uint32) int

func Num11MethodTwo

func Num11MethodTwo(num uint32) int

优解,位运算

func Num12MethodOne

func Num12MethodOne(base float64, exponent int) float64

func Num13MethodOne

func Num13MethodOne(arr []int) []int

func Num13MethodThree

func Num13MethodThree(arr []int) []int

O(N) 优解

func Num13MethodTwo

func Num13MethodTwo(arr []int) []int

不能保证相对位置不变 leetcode版

func Num14MethodOne

func Num14MethodOne(head *ds.LinkNode, k int) *ds.LinkNode

利用快慢指针的思想。将第一个指针 fast 指向链表的第 k + 1 个节点,第二个指针 slow 指向链表的第一个节点,此时指针 fast 与 slow 之间刚好间隔 k 个节点。此时两个指针同步向后走,当第一个指针 fast 走到链表的尾部空节点时,则此时 slow 指针刚好指向链表的倒数第 k 个节点。

func Num16MethodOne

func Num16MethodOne(l1, l2 *ds.LinkNode) *ds.LinkNode

func Num17MethodOne

func Num17MethodOne(a, b *ds.BTree) bool

func Num18MethodOne

func Num18MethodOne(root *ds.BTree) *ds.BTree

二叉树深度优先遍历,遍历过程中进行左右子树交换操作

func Num18MethodTwo

func Num18MethodTwo(root *ds.BTree) *ds.BTree

二叉树先进行递归遍历,找到叶子节点,回溯的过程中进行左右子树交换操作。

func Num19MethodOne

func Num19MethodOne(matrix [][]int) []int

func Num21MethodOne

func Num21MethodOne(pushed, popped []int) bool

解题思路 1,本题主要考察入栈出栈的理解 2,golang slice可以很容易实现栈 3,每次pushed入栈后popped 进行比较 4,如果栈非空,且poped的当前元素和栈顶元素相等,则出栈,同时右移popped指针

func Num22MethodOne

func Num22MethodOne(root *ds.BTree) []int

从上往下打印出二叉树的每个节点,同层节点从左至右打印。

func Num23MethodOne

func Num23MethodOne(postorder []int) bool

二叉搜索树的后序遍历序列 从上往下打印出二叉树的每个节点,同层节点从左至右打印。

根节点的值大于左子树小于右子树 后序遍历: 左子树 -> 右子树 -> 根节点

func Num24MethodOne

func Num24MethodOne(root *ds.BTree, target int) [][]int

func Num25MethodOne

func Num25MethodOne(root *ds.RandomListNode) *ds.RandomListNode

func Num26MethodOne

func Num26MethodOne(root *ds.BTree) *ds.BTree

func Num27MethodOne

func Num27MethodOne(str string) []string

func Num28MethodOne

func Num28MethodOne(nums []int) int

func Num29MethodOne

func Num29MethodOne(nums []int, k int) []int

func Num30MethodOne

func Num30MethodOne(nums []int) int

func SelectSort

func SelectSort(data []int) int

Types

type ArrayStack

type ArrayStack struct {
	Array []string
	Size  int
}

func (*ArrayStack) Pop

func (stack *ArrayStack) Pop() string

func (*ArrayStack) Push

func (stack *ArrayStack) Push(val string)

type MinStack

type MinStack struct {
	Val  []int
	Mini []int
}

func Constructor

func Constructor() MinStack

func (*MinStack) Min

func (minStack *MinStack) Min() int

func (*MinStack) Pop

func (minStack *MinStack) Pop()

func (*MinStack) Push

func (minStack *MinStack) Push(val int)

func (*MinStack) Top

func (minStack *MinStack) Top() int

Jump to

Keyboard shortcuts

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