随笔分类 -  tree

1 2 下一页

[leecode]Scramble String
摘要:Scramble StringGiven a strings1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible... 阅读全文

posted @ 2014-09-01 23:38 喵星人与汪星人 阅读(146) 评论(0) 推荐(0) 编辑

[leecode]Binary Tree Preorder Traversal
摘要:Binary Tree Preorder TraversalGiven a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ ... 阅读全文

posted @ 2014-08-31 17:48 喵星人与汪星人 阅读(184) 评论(0) 推荐(0) 编辑

[leetcode]Binary Tree InorderTraversal
摘要:Binary Tree Inorder TraversalGiven a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ ... 阅读全文

posted @ 2014-08-31 17:44 喵星人与汪星人 阅读(159) 评论(0) 推荐(0) 编辑

[leecode]Word Break II
摘要:Word Break IIGiven a stringsand a dictionary of wordsdict, add spaces insto construct a sentence where each word is a valid dictionary word.Return all... 阅读全文

posted @ 2014-08-24 22:49 喵星人与汪星人 阅读(283) 评论(0) 推荐(0) 编辑

[leetcode]Convert Sorted List to Binary Search Tree
摘要:Convert Sorted List to Binary Search TreeGiven a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.... 阅读全文

posted @ 2014-08-16 10:51 喵星人与汪星人 阅读(311) 评论(0) 推荐(0) 编辑

[leetcode]Sum Root to Leaf Numbers
摘要:Sum Root to Leaf NumbersGiven a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-l... 阅读全文

posted @ 2014-08-16 00:45 喵星人与汪星人 阅读(204) 评论(0) 推荐(0) 编辑

[leetcode]Unique Binary Search Trees
摘要:Unique Binary Search TreesGivenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a to... 阅读全文

posted @ 2014-08-16 00:38 喵星人与汪星人 阅读(159) 评论(0) 推荐(0) 编辑

[leetcode]Unique Binary Search Trees II
摘要:Unique Binary Search Trees IIGivenn, generate all structurally uniqueBST's(binary search trees) that store values 1...n.For example,Givenn= 3, your pr... 阅读全文

posted @ 2014-08-15 22:55 喵星人与汪星人 阅读(281) 评论(0) 推荐(0) 编辑

[leetcode]Binary Tree Maximum Path Sum
摘要:Binary Tree Maximum Path SumGiven a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the be... 阅读全文

posted @ 2014-08-11 19:43 喵星人与汪星人 阅读(212) 评论(0) 推荐(0) 编辑

[leetcode]Binary Tree Postorder Traversal
摘要:Binary Tree Postorder TraversalGiven a binary tree, return thepostordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \... 阅读全文

posted @ 2014-08-08 22:00 喵星人与汪星人 阅读(160) 评论(0) 推荐(0) 编辑

[leetcode]Binary Tree Level Order Traversal II
摘要:Binary Tree Level Order Traversal IIGiven a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level... 阅读全文

posted @ 2014-08-08 21:35 喵星人与汪星人 阅读(143) 评论(0) 推荐(0) 编辑

[leetcode]Binary Tree Level Order Traversal
摘要:Binary Tree Level Order TraversalGiven a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).Fo... 阅读全文

posted @ 2014-08-08 21:26 喵星人与汪星人 阅读(254) 评论(0) 推荐(0) 编辑

[leetcode]Binary Tree Zigzag Level Order Traversal
摘要:Binary Tree Zigzag Level Order TraversalGiven a binary tree, return thezigzag level ordertraversal of its nodes' values. (ie, from left to right, then... 阅读全文

posted @ 2014-08-08 21:11 喵星人与汪星人 阅读(208) 评论(0) 推荐(0) 编辑

[leetcode]Sqrt(x)
摘要:Sqrt(x)Implementint sqrt(int x).Compute and return the square root ofx.【注意】:1.本题int类型可能会溢出,因此不能用乘法运算,应尽量用除法。2. 绝大多数数字都不是可开方的,该如何得到比较近的结果呢?算法思路:思路1:顺序遍... 阅读全文

posted @ 2014-08-08 00:05 喵星人与汪星人 阅读(301) 评论(0) 推荐(0) 编辑

[leetcode]Flatten Binary Tree to Linked List
摘要:Flatten Binary Tree to Linked ListGiven a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / ... 阅读全文

posted @ 2014-08-07 22:53 喵星人与汪星人 阅读(210) 评论(0) 推荐(0) 编辑

[leetcode]Populating Next Right Pointers in Each Node II
摘要:Populating Next Right Pointers in Each Node IIFollow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any ... 阅读全文

posted @ 2014-07-31 20:40 喵星人与汪星人 阅读(174) 评论(0) 推荐(0) 编辑

[leetcode]Populating Next Right Pointers in Each Node
摘要:Populating Next Right Pointers in Each NodeGiven a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLi... 阅读全文

posted @ 2014-07-31 20:35 喵星人与汪星人 阅读(246) 评论(0) 推荐(0) 编辑

[leetcode]Path Sum II
摘要:Path Sum IIGiven a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tr... 阅读全文

posted @ 2014-07-31 20:29 喵星人与汪星人 阅读(151) 评论(0) 推荐(0) 编辑

[leetcode]Path Sum
摘要:Path SumGiven 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 give... 阅读全文

posted @ 2014-07-31 20:27 喵星人与汪星人 阅读(219) 评论(0) 推荐(0) 编辑

[leetcode]Balanced Binary Tree
摘要:Balanced Binary TreeGiven a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tre... 阅读全文

posted @ 2014-07-31 20:22 喵星人与汪星人 阅读(227) 评论(0) 推荐(0) 编辑

1 2 下一页