自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(22)
  • 资源 (2)
  • 收藏
  • 关注

原创 leetcode 450. Delete Node in a BST

Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of the BST.Basically, the deletion can be divided into t

2017-05-31 23:21:37 280

原创 leetcode 230. Kth Smallest Element in a BST

Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.Note: You may assume k is always valid, 1 ? k ? BST's total elements.需要对树进行中序遍历,只是在中的时候做一些处理。public clas

2017-05-31 21:55:26 259

原创 leetcode 124. Binary Tree Maximum Path Sum

Given a binary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The path

2017-05-31 19:59:33 261

原创 leetcode 199. Binary Tree Right Side View

Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.For example:Given the following binary tree, 1

2017-05-31 19:29:19 295

原创 leetcode 129. Sum Root to Leaf Numbers

Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.Find the total sum of al

2017-05-31 17:32:54 301

原创 leetcode 117. Populating Next Right Pointers in Each Node II

Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution still work?Note:You may only use constant extra space.

2017-05-31 17:23:02 293

原创 leetcode 116. Populating Next Right Pointers in Each Node

Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointer to point to its next right node. If there is

2017-05-31 16:50:28 269

原创 leetcode 114. Flatten Binary Tree to Linked List

Total Accepted: 123537Total Submissions: 357891Difficulty: MediumContributor: LeetCodeGiven a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5

2017-05-31 16:33:10 282

原创 leetcode 105&106

105. Construct Binary Tree from Preorder and Inorder Traversal106. Construct Binary Tree from Inorder and Postorder TraversalNote:You may assume that duplicates do not exist in the tree.将手动解法规则化,主要是

2017-05-26 19:47:26 928

原创 leetcode 99. Recover Binary Search Tree

Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is pretty straight forward. Could you devise a consta

2017-05-26 15:19:52 359

原创 leetcode 98. Validate Binary Search Tree

Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less than the node's key.The right

2017-05-26 10:57:51 316

原创 leetcode 95&96. Unique Binary Search Trees

96. Unique Binary Search TreesGiven n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's. 1 3

2017-05-25 23:13:36 488

原创 leetcode 508. Most Frequent Subtree Sum

Given the root of a tree, you are asked to find the most frequent subtree sum. The subtree sum of a node is defined as the sum of all the node values formed by the subtree rooted at that node (includin

2017-05-25 19:43:24 299

原创 leetcode 538. Convert BST to Greater Tree

Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST.Example:I

2017-05-25 17:04:51 292

原创 leetcode 515. Find Largest Value in Each Tree Row

You need to find the largest value in each row of a binary tree.Example:Input: 1 / \ 3 2 / \ \ 5 3 9 Output: [1, 3, 9]这题其实就是个广度优先搜索,一般解法是用队列/** * Def

2017-05-25 16:01:42 482

原创 leetcode 513. Find Bottom Left Tree Value

Given a binary tree, find the leftmost value in the last row of the tree.Example 1:Input: 2 / \ 1 3Output:1Example 2: Input: 1 / \ 2 3 / / \ 4 5 6

2017-05-25 15:37:14 401

原创 Java Queue 一些方法对比

主要是 add()&offer(), remove()&poll(), element&peek()的对比 见官方APIpublic interface Queue<E> extends Collection<E>A collection designed for holding elements prior to processing. Besides basic Collection

2017-05-22 15:02:50 852

原创 leetcode 235&236

235Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between

2017-05-19 16:11:56 2052

原创 leetcode 572. Subtree of Another Tree

Given two non-empty binary trees s and t, check whether tree t has exactly the same structure and node values with a subtree of s. A subtree of s is a tree consists of a node in s and all of this node'

2017-05-19 14:44:02 478

原创 leetcode 563. Binary Tree Tilt

Given a binary tree, return the tilt of the whole tree.The tilt of a tree node is defined as the absolute difference between the sum of all left subtree node values and the sum of all right subtree nod

2017-05-19 11:11:41 339

原创 leetcode 257. Binary Tree Paths

Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \ 2 3 \ 5All root-to-leaf paths are:["1->2->5", "1->3"]分析: 这题递归的解法要点是要记住到达父节点的路径之

2017-05-19 10:50:56 286

原创 leetcode 404. Sum of Left Leaves

Find the sum of all left leaves in a given binary tree.如果采用递归的解法,就需要判断前后两次迭代的关系。 如果树只有一个节点,需要判断其与父节点的关系,如果该节点是左孩子,就直接返回其值,如果是右孩子就返回0。如果还有孩子,就往下递归。 注意到这里有个与父节点关系,按照一般的递归是无法保持这个信息,同时为了递归的简便,不太方便在每次递归里还

2017-05-19 10:12:26 682

迷宫问题求解

经典迷宫问题的求解的C源代码。学习过程中亲自写的运行实用使用回溯法,代码简洁清晰。

2014-09-07

集体智慧编程pdf

集体智慧编程》由美国计算机专家西格兰编著,以机器学习与计算统计为主题背景,专门讲述如何挖掘和分析Web上的数据和资源,如何分析用户体验、市场营销、个人品味等诸多信息,并得出有用的结论,通过复杂的算法来从Web网站获取、收集并分析用户的数据和反馈信息,以便创造新的用户价值和商业价值。

2014-08-07

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除