Flatten a binary tree to a fake "linked list" in pre-order traversal. Here we use the right pointer in TreeNode as the nextpointer in ListNode. Notice ...
分类:
其他好文 时间:
2017-10-13 10:28:21
阅读次数:
160
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 l ...
分类:
其他好文 时间:
2017-10-13 10:24:16
阅读次数:
161
Given a binary tree, find the length of the longest consecutive sequence path. The path refers to any sequence of nodes from some starting node to any ...
分类:
其他好文 时间:
2017-10-13 10:11:47
阅读次数:
121
1 按照排序特性分类 首先按照排序本身的操作特性可以分为下面几种: (1)插入排序 a.直接插入排序(Insert Sort) O(n^2)(稳定) b.折半插入排序(Binary Insert Sort) (不稳定) c.希尔排序(Shell Sort) (不稳定) (2)交换排序 a.冒泡排序( ...
分类:
编程语言 时间:
2017-10-13 00:43:52
阅读次数:
311
1. 原理 Cost function Theta 2. Python 3. C++ ...
分类:
其他好文 时间:
2017-10-12 23:10:42
阅读次数:
170
3441: 乌鸦喝水 Description 【题目背景】 一只乌鸦在自娱自乐,它在面前放了n个有魔力的水缸,水缸里装有无限的水。 【题目描述】 他准备从第1个水缸飞到第n个水缸,共m次。在飞过一个水缸的过程中,如果他能够得着水缸里的水,即水缸口到水面距离小于等于乌鸦能够得着的深度,那它就会喝水缸里 ...
分类:
其他好文 时间:
2017-10-12 23:08:38
阅读次数:
286
Given the root and two nodes in a Binary Tree. Find the lowest common ancestor(LCA) of the two nodes.The lowest common ancestor is the node with large ...
分类:
其他好文 时间:
2017-10-12 14:00:02
阅读次数:
205
Given the root and two nodes in a Binary Tree. Find the lowest common ancestor(LCA) of the two nodes. The lowest common ancestor is the node with larg ...
分类:
其他好文 时间:
2017-10-12 10:13:51
阅读次数:
154
class Solution { public List preorderTraversal(TreeNode root) { Stack stack=new Stack(); List res=new ArrayList(); while(root!=null||!stack.isEmpty())... ...
分类:
其他好文 时间:
2017-10-12 10:08:42
阅读次数:
181