easy

package
v0.0.0-...-bddcb22 Latest Latest
Warning

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

Go to latest
Published: May 16, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsDuplicate

func ContainsDuplicate(nums []int) bool

func ContainsDuplicateHashMap

func ContainsDuplicateHashMap(nums []int) bool

func ContainsDuplicateShort

func ContainsDuplicateShort(nums []int) bool

func FirstUniqChar

func FirstUniqChar(s string) int

@lc code=start

func Generate

func Generate(numRows int) [][]int

经典动态规划求杨辉三角

func Intersect

func Intersect(nums1 []int, nums2 []int) []int

哈希表实现

func IsValid

func IsValid(s string) bool

IsValid 20.有效的括号 搞个栈,压栈判断就可以了

func LongestCommonPrefix

func LongestCommonPrefix(strs []string) string

纵向扫描

func LuckyNumbers

func LuckyNumbers(matrix [][]int) (ans []int)

func MatrixReshape

func MatrixReshape(mat [][]int, r int, c int) [][]int

func Max

func Max(x, y int) int

func MaxProfit

func MaxProfit(prices []int) int

买卖股票的最佳时机 思路: 有两种操作 买/卖 最优化买:对比 上一次买与这次买 选择最省钱的方式 最优化卖:对比 上次卖与这次卖 选择最赚钱的方式 4ms/3.6mb

func MaxProfitOne

func MaxProfitOne(prices []int) int

一次遍历

func MaxProfitPro

func MaxProfitPro(prices []int) int

优化: 内存可以压缩 不用建立二维数组 重复使用买卖变量 4ms/3.1mb

func MaxSubArray

func MaxSubArray(nums []int) int

func MaxSubArrayDivideConquer

func MaxSubArrayDivideConquer(nums []int) int

func MaxSubArrayDynamic

func MaxSubArrayDynamic(nums []int) int

func Merge

func Merge(nums1 []int, m int, nums2 []int, n int)

直接合并后排序

func MergeTwoLists

func MergeTwoLists(list1 *medium.ListNode, list2 *medium.ListNode) *medium.ListNode

func MergeTwoPoint

func MergeTwoPoint(nums1 []int, m int, nums2 []int, n int)

双指针

func MergeTwoPointReverse

func MergeTwoPointReverse(nums1 []int, m int, nums2 []int, n int)

逆向双指针

func MinimumDifference

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

func ShortestCompletingWord

func ShortestCompletingWord(licensePlate string, words []string) (ans string)

统计 licensePlate 中每个字母的出现次数(忽略大小写) 然后遍历 words 中的每个单词 若 26 个字母在该单词中的出现次数均不小于在 licensePlate 中的出现次数,则该单词是一个补全词 返回最短且最靠前的补全词

func StrStr

func StrStr(haystack string, needle string) int

func TotalMoney

func TotalMoney(n int) (ans int)

因为每周七天存的钱之和比上一周多 77 块,因此每周存的钱之和的序列是一个等差数列,我们可以用等差数列求和公式来求出所有完整的周存的钱总和。 剩下的天数里,每天存的钱也是一个等差数列,可以用相同的公式进行求和。最后把两者相加可以得到答案。

Types

type MinStack

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

func MinStackConstructor

func MinStackConstructor() MinStack

func (*MinStack) GetMin

func (this *MinStack) GetMin() int

func (*MinStack) Pop

func (this *MinStack) Pop()

func (*MinStack) Push

func (this *MinStack) Push(x int)

func (*MinStack) Top

func (this *MinStack) Top() int

type MovingAverage

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

func Constructor

func Constructor(size int) MovingAverage

* Initialize your data structure here.

func (*MovingAverage) Next

func (this *MovingAverage) Next(val int) float64

type Node590

type Node590 struct {
	Val      int
	Children []*Node590
}

type OrderedStream

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

func OrderedStreamConstructor

func OrderedStreamConstructor(n int) OrderedStream

func (*OrderedStream) Insert

func (s *OrderedStream) Insert(idKey int, value string) []string

type Status

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

type TreeNode

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

Jump to

Keyboard shortcuts

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