上一页 1 2 3 4 5 6 7 ··· 58 下一页
摘要: //一使用一个中间数组 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 知道了呀~ 阅读(56) 评论(0) 推荐(0) 编辑
摘要: 给定一个二叉树, 找到该树中两个指定节点间的最短距离 // A// B C//D E F// D E --> 2// E F --> 4解法一:先求两节点的最近公共祖先,然后层序遍历求三个节点所在位置的深度,然后距离加减就行 func main() { //按数组层序建立二叉树 root:=crea 阅读全文
posted @ 2022-07-03 16:38 知道了呀~ 阅读(242) 评论(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 知道了呀~ 阅读(54) 评论(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 知道了呀~ 阅读(62) 评论(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 知道了呀~ 阅读(175) 评论(2) 推荐(1) 编辑
摘要: https://leetcode.cn/problems/intersection-of-two-linked-lists/solution/xiang-jiao-lian-biao-by-leetcode-solutio-a8jn/ /** * Definition for singly-link 阅读全文
posted @ 2022-07-01 12:07 知道了呀~ 阅读(50) 评论(0) 推荐(0) 编辑
摘要: 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 知道了呀~ 阅读(40) 评论(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 知道了呀~ 阅读(58) 评论(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 知道了呀~ 阅读(46) 评论(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 知道了呀~ 阅读(55) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 58 下一页