上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 44 下一页
摘要: 关联问题:排列1:46. Permutations, 排列2:47. Permutations II,组合:77. Combinations 问题: 给定一个数组,求对该数组进行全排列的所有结果。 Example 1: Input: nums = [1,2,3] Output: [[1,2,3],[ 阅读全文
posted @ 2020-12-29 14:02 habibah_chang 阅读(90) 评论(0) 推荐(0) 编辑
摘要: 问题: 给定一颗BST(二叉搜索树),其中存在两个节点顺序颠倒,请找出他们,并恢复正确次序。 Example 1: Input: root = [1,3,null,null,2] Output: [3,1,null,null,2] Explanation: 3 cannot be a left ch 阅读全文
posted @ 2020-12-05 12:20 habibah_chang 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 参考:labuladong 问题: 判断一个链表,是否为回文链表。 Example 1: Input: 1->2 Output: false Example 2: Input: 1->2->2->1 Output: true 解法: 解法一:Linked List Traverse 链表遍历(后序遍 阅读全文
posted @ 2020-11-22 09:41 habibah_chang 阅读(91) 评论(0) 推荐(0) 编辑
摘要: 问题: 给定一个字符串,求最少添加几个字母,能使的字符串成为回文字符串。 Example 1: Input: s = "zzazz" Output: 0 Explanation: The string "zzazz" is already palindrome we don't need any i 阅读全文
posted @ 2020-11-15 12:20 habibah_chang 阅读(93) 评论(0) 推荐(0) 编辑
摘要: 问题: 给定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: 阅读全文
posted @ 2020-10-25 10:44 habibah_chang 阅读(111) 评论(0) 推荐(0) 编辑
摘要: 问题: 给定一棵二叉树,对所有节点为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, 阅读全文
posted @ 2020-10-18 16:29 habibah_chang 阅读(97) 评论(0) 推荐(0) 编辑
摘要: 124. Binary Tree Maximum Path Sum 问题: 求出给定二叉树中,最大路径和(节点权值相加)。(至少包含树中一个节点) Example 1: Input: [1,2,3] 1 / \ 2 3 Output: 6 Example 2: Input: [-10,9,20,nu 阅读全文
posted @ 2020-10-04 11:42 habibah_chang 阅读(100) 评论(0) 推荐(0) 编辑
摘要: 参考:labuladong 递归反转链表的一部分 labubadong 如何k个一组反转链表 问题: 206.链表反转。 Example: Input: 1->2->3->4->5->NULL Output: 5->4->3->2->1->NULL 92.指定区间链表反转。 Note: 1 ≤ m 阅读全文
posted @ 2020-10-01 20:55 habibah_chang 阅读(132) 评论(0) 推荐(0) 编辑
摘要: Binary Search Tree 二叉搜索树问题。 遍历框架: 1 void BST(TreeNode root, int target) { 2 if (root.val == target) 3 // 找到目标,做点什么 4 if (root.val < target) 5 BST(root 阅读全文
posted @ 2020-10-01 14:15 habibah_chang 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 问题: 判断一颗二叉树是否为二叉搜索树。 解法:Binary Tree(二叉树) 首先,了解 二叉搜索树BST的定义: A binary search tree is a rooted binary tree whose internal nodes each store a key greater 阅读全文
posted @ 2020-10-01 13:57 habibah_chang 阅读(160) 评论(0) 推荐(0) 编辑
上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 44 下一页