上一页 1 2 3 4 5 6 7 8 9 10 ··· 59 下一页
摘要: https://leetcode.cn/problems/3sum/ func threeSum(nums []int)[][]int{ ans:=make([][]int,0) len:=len(nums) if len<3{ return ans } sort.Ints(nums) for i: 阅读全文
posted @ 2022-06-21 17:59 知道了呀~ 阅读(170) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/two-sum/ func twoSum(nums []int, target int) []int { mp:=make(map[int]int,len(nums)) //某个数字出现的次数 for i := range nums { if 阅读全文
posted @ 2022-06-21 17:58 知道了呀~ 阅读(87) 评论(0) 推荐(0)
摘要: 常用的设计模式 单例、工厂、观察者、发布订阅、责任链、适配器等 // 单例模式 //单例模式保证系统特定的类或者是结构体对象只有一个实例,是保障系统//实例唯一性的重要手段。 // 饿汉式 //在类创建的时候就已经实例化好了对象,只实例化一次,是线程安全的 //实现: 1、通过init()函数实现 阅读全文
posted @ 2022-06-21 14:36 知道了呀~ 阅读(105) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/trapping-rain-water-ii/ func trapRainWater(heightMap [][]int) int { m, n := len(heightMap), len(heightMap[0]) maxHeight : 阅读全文
posted @ 2022-06-20 15:53 知道了呀~ 阅读(173) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/zheng-ze-biao-da-shi-pi-pei-lcof/ func isMatch(s string, p string) bool { n:=len(s);m:=len(p) vis:=make([][]bool,0,n+1) / 阅读全文
posted @ 2022-06-20 15:15 知道了呀~ 阅读(71) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/reverse-nodes-in-k-group/ func main(){ h:=newList() ans:=reverseKGroup(h,3) for ans!=nil{ fmt.Println(ans.Val) ans=ans.Ne 阅读全文
posted @ 2022-06-17 15:15 知道了呀~ 阅读(73) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/best-time-to-buy-and-sell-stock/ func maxProfit(prices []int) int { n:=len(prices) vis:=make([]int,n+1) for i:=n-1;i>=0;i 阅读全文
posted @ 2022-06-17 14:20 知道了呀~ 阅读(65) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/k-diff-pairs-in-an-array/ func findPairs(nums []int, k int) int { mp:=make(map[int]bool,0) //标记 ans:=make(map[int]bool,0) 阅读全文
posted @ 2022-06-16 15:12 知道了呀~ 阅读(69) 评论(0) 推荐(0)
摘要: func consume() { ch := make(chan string, 30) wg := sync.WaitGroup{} mu := sync.Mutex{} wg.Add(1) go func() { defer wg.Done() for { mu.Lock() if len(ch 阅读全文
posted @ 2022-06-15 21:34 知道了呀~ 阅读(113) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/kth-largest-element-in-an-array/ func findKthLargest(nums []int, k int) int { //quickPow(0,len(nums)-1,nums) //guibin(0,l 阅读全文
posted @ 2022-06-13 23:07 知道了呀~ 阅读(78) 评论(1) 推荐(1)
上一页 1 2 3 4 5 6 7 8 9 10 ··· 59 下一页