随笔分类 -  LeetCode

java 代码练习
摘要:有序链表0->1->2->3->4->5转换为一个二叉排序树。我们在此创建一个平衡二叉排序树1.先找链表到中间的节点2.中间节点的val创建一个新的树节点TreeNode3.将链表断裂为2部分4.递归创建左子树和右子树#include#includeusing namespace std;struc... 阅读全文
posted @ 2015-06-03 20:26 hitkb 阅读(155) 评论(0) 推荐(0)
摘要:【LeetCode】Minimum Depth of Binary TreeGiven a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path fro... 阅读全文
posted @ 2015-01-23 11:18 hitkb 阅读(233) 评论(0) 推荐(0)
摘要:在Path SUm 1中(http://www.cnblogs.com/hitkb/p/4242822.html)我们采用栈的形式保存路径,每当找到符合的叶子节点,就将栈内元素输出。注意存在多条路径的情况。 public List> pathSum(TreeNode root, int sum) {... 阅读全文
posted @ 2015-01-23 10:07 hitkb 阅读(212) 评论(0) 推荐(0)
摘要:Path Sum 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 giv... 阅读全文
posted @ 2015-01-22 22:01 hitkb 阅读(488) 评论(0) 推荐(0)
摘要:随笔一记,留做重温!Flatten Binary Tree to Linked ListGiven a binary tree, flatten it to a linked list in-place. For example,Given 1 / \ 2 ... 阅读全文
posted @ 2015-01-22 17:10 hitkb 阅读(121) 评论(0) 推荐(0)
摘要:编程小记,已供重温!!Populating Next Right Pointers in Each NodeGiven a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; ... 阅读全文
posted @ 2014-11-29 15:26 hitkb 阅读(163) 评论(0) 推荐(0)