上一页 1 2 3 4 5 6 ··· 58 下一页
摘要: https://leetcode.cn/problems/open-the-lock/solution/shou-hua-tu-jie-tu-bfs-lin-jie-guan-xi-7-ud8c/ func openLock(deadends []string, target string) int 阅读全文
posted @ 2022-07-11 14:44 知道了呀~ 阅读(56) 评论(0) 推荐(0) 编辑
摘要: https://leetcode.cn/problems/permutations/ var ans [][]int var vis map[int]bool func permute(nums []int) [][]int { path:=make([]int,0) ans=make([][]in 阅读全文
posted @ 2022-07-10 22:08 知道了呀~ 阅读(53) 评论(0) 推荐(0) 编辑
摘要: https://leetcode.cn/problems/maximum-subarray/ func maxSubArray(nums []int) int { maxAns:=-99999999999 len:=len(nums) ans:=0;begin:=0 le:=0;ri:=len-1 阅读全文
posted @ 2022-07-09 22:26 知道了呀~ 阅读(59) 评论(0) 推荐(0) 编辑
摘要: 一、求数组局部最大值 func findMax(nums []int) int{//只能从nums里面随机找到一个符合局部最大的数字 le:=0;ri:=len(nums)-1 for le<ri{ mid:=(le+ri)/2 if nums[mid]>nums[mid+1]{ ri=mid }e 阅读全文
posted @ 2022-07-08 14:43 知道了呀~ 阅读(202) 评论(0) 推荐(0) 编辑
摘要: https://leetcode.cn/problems/8Zf90G/ func evalRPN(tokens []string) int { stack := make([]int,0) for _, token := range tokens { val, err := strconv.Ato 阅读全文
posted @ 2022-07-06 20:11 知道了呀~ 阅读(61) 评论(0) 推荐(0) 编辑
摘要: https://leetcode.cn/problems/4sum-ii/solution/si-shu-xiang-jia-ii-by-leetcode-solution/ 时间复杂度和空间复杂度都是O(n2) func fourSumCount(a, b, c, d []int) (ans in 阅读全文
posted @ 2022-07-06 17:48 知道了呀~ 阅读(61) 评论(0) 推荐(0) 编辑
摘要: 一、redis set nx实现限流 比如我们需要在10秒内限定20个请求,那么我们在setnx的时候可以设置过期时间为当前时间戳+10s,使用set nx 设置20个互不相同的key,当请求的setnx数量达到20时候即达到了限流效果。 当然这种做法的弊端是很多的,比如当统计1-10秒的时候,无法 阅读全文
posted @ 2022-07-06 10:51 知道了呀~ 阅读(1358) 评论(0) 推荐(0) 编辑
摘要: https://learnku.com/articles/46788 阅读全文
posted @ 2022-07-05 17:11 知道了呀~ 阅读(64) 评论(0) 推荐(0) 编辑
摘要: https://www.nowcoder.com/practice/d3df40bd23594118b57554129cadf47b?tpId=295&tqId=1499549&ru=/exam/oj&qru=/ta/format-top101/question-ranking&sourceUrl= 阅读全文
posted @ 2022-07-05 11:23 知道了呀~ 阅读(52) 评论(0) 推荐(0) 编辑
摘要: //一使用一个中间数组 func merge(nums1 []int, m int, nums2 []int, n int) { tmp:=make([]int,n+m) copy(tmp,nums1)//深拷贝 i:=0;j:=0;k:=0 for i<m&&j<n{ if tmp[i]>nums 阅读全文
posted @ 2022-07-04 21:06 知道了呀~ 阅读(55) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 58 下一页