06 2022 档案

摘要:https://leetcode.cn/problems/er-cha-shu-de-jing-xiang-lcof/ /** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNo 阅读全文
posted @ 2022-06-30 21:01 知道了呀~ 阅读(54) 评论(0) 推荐(0) 编辑
摘要:https://leetcode.cn/problems/er-wei-shu-zu-zhong-de-cha-zhao-lcof/ func findNumberIn2DArray(matrix [][]int, target int) bool { return find2(matrix,tar 阅读全文
posted @ 2022-06-30 19:46 知道了呀~ 阅读(79) 评论(0) 推荐(0) 编辑
摘要:https://leetcode.cn/problems/path-sum-ii/ /** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNo 阅读全文
posted @ 2022-06-29 21:53 知道了呀~ 阅读(63) 评论(0) 推荐(0) 编辑
摘要:https://leetcode.cn/problems/SLwz0R/ /** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } */ func removeNt 阅读全文
posted @ 2022-06-29 20:47 知道了呀~ 阅读(74) 评论(0) 推荐(0) 编辑
摘要:https://leetcode.cn/problems/P5rCT8/ /** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * 阅读全文
posted @ 2022-06-28 21:33 知道了呀~ 阅读(84) 评论(0) 推荐(0) 编辑
摘要:链接:https://www.nowcoder.com/questionTerminal/a2a1d0266629404fba582d416d84b6a0来源:牛客网 把 M 个同样的苹果放在 N 个同样的盘子里,允许有的盘子空着不放,问共有多少种不同的分法? 注意:5、1、1 和 1、5、1 是同 阅读全文
posted @ 2022-06-28 21:06 知道了呀~ 阅读(155) 评论(0) 推荐(0) 编辑
摘要:https://leetcode.cn/problems/bulb-switcher/ 阅读全文
posted @ 2022-06-28 15:34 知道了呀~ 阅读(81) 评论(0) 推荐(0) 编辑
摘要:https://leetcode.cn/problems/shu-de-zi-jie-gou-lcof/ /** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Ri 阅读全文
posted @ 2022-06-28 10:54 知道了呀~ 阅读(107) 评论(0) 推荐(0) 编辑
摘要:组合总数 II https://leetcode.cn/problems/combination-sum-ii/ 题解:https://leetcode.cn/problems/combination-sum-ii/solution/dai-ma-sui-xiang-lu-dai-ni-xue-to 阅读全文
posted @ 2022-06-27 16:27 知道了呀~ 阅读(71) 评论(0) 推荐(0) 编辑
摘要:零钱兑换一:求兑换最少硬币数 https://leetcode.cn/problems/coin-change/ func coinChange(coins []int, amount int) int { dp:=make([]int,amount+1) //dp[i]标识金额为i的时候,需要的最 阅读全文
posted @ 2022-06-27 14:25 知道了呀~ 阅读(213) 评论(0) 推荐(0) 编辑
摘要:最多包含k个字符类型的子串 注意的是,k标识字符类型,不是次数 func findStr(s string,k int)int{ mxAns:=0 sLen:=len(s) if sLen<=k{ return sLen } mp :=make(map[byte]int) le:=0;ri:=0 / 阅读全文
posted @ 2022-06-26 19:19 知道了呀~ 阅读(210) 评论(0) 推荐(0) 编辑
摘要:https://leetcode.cn/problems/ZL6zAn/ var n,m,ans int var dir =[][]int{{1,0},{0,1},{-1,0},{0,-1}} func checkRange(x,y int) bool{ if x>=0&&x<n&&y>=0&&y< 阅读全文
posted @ 2022-06-26 18:00 知道了呀~ 阅读(62) 评论(0) 推荐(0) 编辑
摘要:func deleteDuplicates( head *ListNode ) *ListNode { new := &ListNode{Next:head} pre,cur := new,head for cur != nil{ for cur.Next != nil && cur.Val == 阅读全文
posted @ 2022-06-26 17:27 知道了呀~ 阅读(69) 评论(0) 推荐(0) 编辑
摘要:https://leetcode.cn/problems/search-in-rotated-sorted-array/ 解题思路: 1、数组旋转之后,分成了两个递增区间,所以第一个步骤就是确定mid位置在那个区间里面 2、在比较mid和target的大小,确定target在区间的左边还是右边 3、 阅读全文
posted @ 2022-06-25 23:00 知道了呀~ 阅读(87) 评论(0) 推荐(0) 编辑
摘要:https://leetcode.cn/problems/merge-intervals/ func merge(intervals [][]int) [][]int { sort.Slice(intervals, func(i, j int) bool { return intervals[i][ 阅读全文
posted @ 2022-06-25 16:11 知道了呀~ 阅读(69) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2022-06-23 20:10 知道了呀~ 阅读(65) 评论(0) 推荐(0) 编辑
摘要:func trailingZeroes(n int) int { ans:=0 for n!=0{ n=n/5 ans=ans+n } return ans } 阅读全文
posted @ 2022-06-22 11:27 知道了呀~ 阅读(72) 评论(0) 推荐(0) 编辑
摘要:https://leetcode.cn/problems/longest-substring-without-repeating-characters/ func lengthOfLongestSubstring(s string) int { mp:=make(map[string]int) le 阅读全文
posted @ 2022-06-22 11:18 知道了呀~ 阅读(64) 评论(0) 推荐(0) 编辑
摘要:题目连接:https://leetcode.cn/problems/sort-list/ 快排(使用快排容易超时,建议使用归并排序) func main(){ head:=&ListNode{} end:=head aaa:=0 for i:=0;i<6;i++{ if i%2==0{ aaa=i 阅读全文
posted @ 2022-06-21 22:31 知道了呀~ 阅读(138) 评论(0) 推荐(0) 编辑
摘要: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 知道了呀~ 阅读(164) 评论(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 知道了呀~ 阅读(80) 评论(0) 推荐(0) 编辑
摘要:常用的设计模式 单例、工厂、观察者、发布订阅、责任链、适配器等 // 单例模式 //单例模式保证系统特定的类或者是结构体对象只有一个实例,是保障系统//实例唯一性的重要手段。 // 饿汉式 //在类创建的时候就已经实例化好了对象,只实例化一次,是线程安全的 //实现: 1、通过init()函数实现 阅读全文
posted @ 2022-06-21 14:36 知道了呀~ 阅读(93) 评论(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 知道了呀~ 阅读(166) 评论(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 知道了呀~ 阅读(64) 评论(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 知道了呀~ 阅读(67) 评论(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 知道了呀~ 阅读(63) 评论(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 知道了呀~ 阅读(66) 评论(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 知道了呀~ 阅读(110) 评论(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 知道了呀~ 阅读(73) 评论(1) 推荐(1) 编辑
摘要:一、zset相关操作 zrangebyscore:从zset拿出区间在[n,m]内的元素值zadd:往zset添加一个元素zrem:删除一个元素多消费者异步消费数据的时候,先从zset拿到数据,然后删除数据,最后再去消费数据,这样可以确保任务不被其他消费者消费到 package delayqueue 阅读全文
posted @ 2022-06-06 15:01 知道了呀~ 阅读(364) 评论(0) 推荐(0) 编辑
摘要:已知random_m()随机数生成器的范围是[1, m] 求random_n()生成[1, n]范围的函数,m < n && n <= m *m一般解法: int random_n() { int val = 0 ; int t; // t为n最大倍数,且满足 t <= m * m do { val 阅读全文
posted @ 2022-06-05 16:56 知道了呀~ 阅读(83) 评论(0) 推荐(0) 编辑
摘要:func firstMissingPositive(nums []int) int { size:=len(nums) for i:=0;i<size;i++{ if nums[i]<=0{ nums[i]=size+1 } } for i:=0;i<size;i++{ origin:=abs(nu 阅读全文
posted @ 2022-06-05 15:18 知道了呀~ 阅读(63) 评论(0) 推荐(0) 编辑
摘要:一个无序数组找其子序列构成的和最大,要求子序列中的元素在原数组中两两都不相邻: func GetSum(nums []int)int { len:=len(nums) if len==0{ return -1 } if len==1{ return nums[0] } if len==2{ retu 阅读全文
posted @ 2022-06-04 18:37 知道了呀~ 阅读(215) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示