码迷,mamicode.com
首页 >  
搜索关键字:binary    ( 11734个结果)
[Leetcode] Construct Binary Tree from Inorder and Postorder Traversal I,II
这两个问题实际上是同一个问题,需要对三种遍历方式的规律非常清楚。对于前序遍历,第一个元素实际上就是root,然后后面的元素前半部分是左树的node,后半部分是右树的node对于中序遍历,一旦我们知道了root节点,那么就可以将其分为两半部分,也就是左树和右树对于后序遍历,我们可以缺点最后一个节点是r...
分类:其他好文   时间:2015-08-15 19:50:05    阅读次数:128
[LeetCode] Search Insert Position
The basic idea is to use binary search: keep two pointerslandrfor the current search range, then find the middle elementnums[mid]in this range. Ifnums...
分类:其他好文   时间:2015-08-15 19:44:56    阅读次数:76
hdu5375 Gray code
Problem Description The reflected binary code, also known as Gray code after Frank Gray, is a binary numeral system where two successive values differ in only onebit (binary digit). The reflected b...
分类:其他好文   时间:2015-08-15 18:26:59    阅读次数:127
[LeetCode] Search for a Range
The idea is to search for the left and right boundaries of target via two binary searches. Well, some tricks may be needed. Take a look at this link :...
分类:其他好文   时间:2015-08-15 18:10:48    阅读次数:96
[Leetcode] Unique Binary Search Trees I,II
一、Unique Binary Search TreesI统计个数迭代的方法可以解决。f(0)=1,f(1)=1,f(2)=2,f(3)=3.f(4)=f(0)*f(3)+f(1)*f(2)+f(2)*f(1)+f(3)*f(0)=10;f(5)=f(0)*f(4)+f(1)*f(3)+f(2)*f...
分类:其他好文   时间:2015-08-15 18:00:17    阅读次数:92
[Leetcode] Binary Tree Level order travelsal (normal and zigzag and bottom-up )
一、normal fasion使用queue记录上次访问的是记录的孩子节点 1 public List> levelOrder(TreeNode root) { 2 List> res = new LinkedList>(); 3 Queue queue = new LinkedLi...
分类:其他好文   时间:2015-08-15 17:51:51    阅读次数:173
pat04-树4. Root of AVL Tree (25)
04-树4. Root of AVL Tree (25)时间限制100 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者CHEN, YueAn AVL tree is a self-balancing binary search tree. In an AVL tre...
分类:其他好文   时间:2015-08-15 17:51:19    阅读次数:125
LeetCode-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 6 The flattened tree should look like: 1...
分类:其他好文   时间:2015-08-15 16:33:08    阅读次数:140
LeetCode-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.Th...
分类:其他好文   时间:2015-08-15 16:31:50    阅读次数:107
pat03-树3. Tree Traversals Again (25)
03-树3. Tree Traversals Again (25)时间限制200 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者CHEN, YueAn inorder binary tree traversal can be implemented in a non...
分类:其他好文   时间:2015-08-15 13:24:55    阅读次数:95
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!