上一页 1 2 3 4 5 6 7 ··· 59 下一页
摘要: 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 知道了呀~ 阅读(86) 评论(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 知道了呀~ 阅读(91) 评论(0) 推荐(0)
摘要: 一、redis set nx实现限流 比如我们需要在10秒内限定20个请求,那么我们在setnx的时候可以设置过期时间为当前时间戳+10s,使用set nx 设置20个互不相同的key,当请求的setnx数量达到20时候即达到了限流效果。 当然这种做法的弊端是很多的,比如当统计1-10秒的时候,无法 阅读全文
posted @ 2022-07-06 10:51 知道了呀~ 阅读(1446) 评论(0) 推荐(0)
摘要: https://learnku.com/articles/46788 阅读全文
posted @ 2022-07-05 17:11 知道了呀~ 阅读(85) 评论(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 知道了呀~ 阅读(74) 评论(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 知道了呀~ 阅读(78) 评论(0) 推荐(0)
摘要: 给定一个二叉树, 找到该树中两个指定节点间的最短距离 // A// B C//D E F// D E --> 2// E F --> 4解法一:先求两节点的最近公共祖先,然后层序遍历求三个节点所在位置的深度,然后距离加减就行 func main() { //按数组层序建立二叉树 root:=crea 阅读全文
posted @ 2022-07-03 16:38 知道了呀~ 阅读(480) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/rotate-list/solution/xiang-zi-xing-che-lian-yi-yang-qu-xuan-z-di8y/ /** * Definition for singly-linked list. * type ListN 阅读全文
posted @ 2022-07-01 16:30 知道了呀~ 阅读(81) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/lowest-common-ancestor-of-a-binary-tree/solution/236-er-cha-shu-de-zui-jin-gong-gong-zu-xian-hou-xu/ /** * Definition for 阅读全文
posted @ 2022-07-01 15:56 知道了呀~ 阅读(93) 评论(0) 推荐(0)
摘要: func main() { //按数组层序建立二叉树,之后层序输出二叉树 root:=createTree(0,[]int{1,2,3,4,5,6}) ans:=printTree(root) fmt.Println(ans) //先序建立二叉树,之后先序输出二叉树 var tmp *TreeNod 阅读全文
posted @ 2022-07-01 15:51 知道了呀~ 阅读(206) 评论(2) 推荐(1)
上一页 1 2 3 4 5 6 7 ··· 59 下一页