摘要: Given inorder and postorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree. 阅读全文
posted @ 2016-05-23 08:59 Adding 阅读(162) 评论(0) 推荐(0) 编辑
摘要: Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree. 阅读全文
posted @ 2016-05-22 21:18 Adding 阅读(124) 评论(0) 推荐(0) 编辑
摘要: /** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ public class Solution { pu... 阅读全文
posted @ 2016-05-22 16:03 Adding 阅读(448) 评论(0) 推荐(0) 编辑
摘要: Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 阅读全文
posted @ 2016-05-20 22:58 Adding 阅读(119) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. F 阅读全文
posted @ 2016-05-20 11:33 Adding 阅读(163) 评论(0) 推荐(0) 编辑
摘要: class TreeNode { int val; TreeNode left; TreeNode right; TreeNode(int x) { val = x; } } public class Solution { public boolean isBalanced(TreeNode root) { if(root==nu... 阅读全文
posted @ 2016-05-20 09:47 Adding 阅读(533) 评论(0) 推荐(0) 编辑
摘要: class TreeNode { int val; TreeNode left; TreeNode right; TreeNode(int x) { val = x; } } public class Solution { public int sumNumbers(TreeNode root) { if(root==null)... 阅读全文
posted @ 2016-05-19 14:34 Adding 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 图解: 此题过程分为三个阶段,分别是 1、负责后面一个节点,并且将这个节点插入到原来链表中 2、复制后面一个节点的random指针。 3 拆分组合链表为两部分。 第一部分代码: 第二部分 代码: 第三部分代码: 总的代码: 阅读全文
posted @ 2016-05-19 09:27 Adding 阅读(465) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull. Follow up: Can you solve it without using extra space? 阅读全文
posted @ 2016-05-18 20:52 Adding 阅读(194) 评论(0) 推荐(0) 编辑
摘要: Given a singly linked list L: L0→L1→…→Ln-1→Ln, reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must do this in-place without altering the nodes' values. Fo 阅读全文
posted @ 2016-05-18 16:32 Adding 阅读(262) 评论(0) 推荐(0) 编辑