- 博客(15)
- 资源 (6)
- 收藏
- 关注
原创 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
2015-08-23 14:47:20 990
原创 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.
2015-08-23 14:44:25 922
原创 leetCode 115.Distinct Subsequences(子序列距离) 解题思路和方法
Given a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string is a new string which is formed from the original string by deleting some (can be non
2015-08-22 22:42:06 1670
原创 leetcode 114.Flatten Binary Tree to Linked List (将二叉树转换链表) 解题思路和方法
Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look like: 1
2015-08-22 22:35:48 1236
原创 leetcode 113. Path Sum II (路径和) 解题思路和方法
Given 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 tree and sum = 22, 5 / \
2015-08-22 22:27:30 1148
原创 leetCode 112.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 given sum.For example:Given the below binary tree and sum
2015-08-05 12:55:20 1161
原创 leetCode 111.Minimum Depth of Binary Tree(二叉树最小深度) 解题思路和方法
Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.思路:求解根节点到叶子的最小距离。与求树的最大深度类似,只是一个求大,一
2015-08-05 12:52:25 530
原创 leetCode 110.Balanced Binary Tree (平衡二叉树) 解题思路和方法
Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never diffe
2015-08-05 12:50:00 891
原创 LeeCode 109.Convert Sorted List to Binary Search Tree(将排序链表转化为BST) 解题思路和方法
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.思路:此题与排序数组很大的不同是链表不知道长度以及上面的值。其整体思路还是中间值作为根节点,但是需要一点策略,不然就会超时。先整体遍历长度之后,将长度保存,这样就不需要每
2015-08-05 12:47:00 698
原创 leetCode 108.Convert Sorted Array to Binary Search Tree(将排序数组转换为BST) 解题思路和方法
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.思路:将排序数组转换为高度平衡的二叉搜索树。思想是将中间的值作为根节点,然后左右的数组分别为左右子树。递归求解。代码如下:/** * Definition for a binary tre
2015-08-05 12:41:47 666
原创 leetCode 107.Binary Tree Level Order Traversal II (二叉树水平序)
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree {3,9,20,#,#,15,7},
2015-08-01 20:27:29 707
原创 leetCode 106.Construct Binary Tree from Inorder and Postorder Traversal (根据中序遍历和后序遍历构造二叉树)
Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.思路:这题和上题类似,前序第一个是根节点,后序遍历最后一个是根节点。其余步骤类似。代码如下:/** *
2015-08-01 20:23:22 664
原创 leetCode 105.Construct Binary Tree from Preorder and Inorder Traversal (根据前序遍历和中序遍历构造二叉树)
Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.思路:首先根据前序遍历得到根节点,然后在中序遍历中得到根节点的位置,左边的为左子树,右边的为右子树。然后再
2015-08-01 20:22:15 636
原创 leetCode 104.Maximum Depth of Binary Tree(二叉树最大深度) 解题思路和方法
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.思路:很基础的一个题,DFS即可。代码如下:/** * Defin
2015-08-01 20:18:18 827
原创 leetCode 103.Binary Tree Zigzag Level Order Traversal (二叉树Z字形水平序) 解题思路和方法
Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).For example:Given binary
2015-08-01 20:17:11 594
hellocharts-library-1.5.8.jar
2015-12-24
libBaiduMapSDK_v3_0_0
2015-07-30
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人