10 2020 档案
摘要:问题: 给定k个有序链表,将这些链表的所有节点排序,组合成一个新的有序链表。 Example 1: Input: lists = [[1,4,5],[1,3,4],[2,6]] Output: [1,1,2,3,4,4,5,6] Explanation: The linked-lists are:
阅读全文
摘要:问题: 给定一棵二叉树,对所有节点为root的子树,若存在重复的子树。将该节点加入res。 Example 1: Input: root = [1,2,3,4,null,2,4,null,null,4] Output: [[2,4],[4]] Example 2: Input: root = [2,
阅读全文
摘要:124. Binary Tree Maximum Path Sum 问题: 求出给定二叉树中,最大路径和(节点权值相加)。(至少包含树中一个节点) Example 1: Input: [1,2,3] 1 / \ 2 3 Output: 6 Example 2: Input: [-10,9,20,nu
阅读全文
摘要:参考:labuladong 递归反转链表的一部分 labubadong 如何k个一组反转链表 问题: 206.链表反转。 Example: Input: 1->2->3->4->5->NULL Output: 5->4->3->2->1->NULL 92.指定区间链表反转。 Note: 1 ≤ m
阅读全文
摘要:Binary Search Tree 二叉搜索树问题。 遍历框架: 1 void BST(TreeNode root, int target) { 2 if (root.val == target) 3 // 找到目标,做点什么 4 if (root.val < target) 5 BST(root
阅读全文
摘要:问题: 判断一颗二叉树是否为二叉搜索树。 解法:Binary Tree(二叉树) 首先,了解 二叉搜索树BST的定义: A binary search tree is a rooted binary tree whose internal nodes each store a key greater
阅读全文