码迷,mamicode.com
首页 >  
搜索关键字:binary trees    ( 12390个结果)
[LeetCode] Flatten Binary Tree to Linked List
大象放入冰箱几步的思路处理这问题就好了 1.把左子树弄平, 2. 插入到根节点和根节点的右子树之间,3. 重复1,2 思路不难,代码上有点混乱,细节实现是:把root的左子树弄成flatten的 flatten(root.left),把右子树保存起来 temp=root.right,让root.right=root.left, 然后断掉左边,root.left=null. 然后一直走到右边的...
分类:其他好文   时间:2014-10-07 06:20:13    阅读次数:194
Add Binary
Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".类似模拟十进制加法 1 class Solution { 2 public: 3 st...
分类:其他好文   时间:2014-10-07 00:00:40    阅读次数:165
Poj 2499 Binary Tree
题目链接:http://poj.org/problem?id=2499思路: 结点向左边移动时结点(a, b)变为( a+b, b),向右边移动时( a, b )变为( a, a + b); 为求最短路径,考虑从已经知道的结点(a, b)开始找出最短路径回到根节点(1, 1); 即向左移动次数...
分类:其他好文   时间:2014-10-06 23:44:30    阅读次数:166
Linux /bin、/sbin、/usr/bin、/usr/sbin目录的区别
在linux下我们经常用到的四个应用程序的目录是/bin、/sbin、/usr/bin、/usr/sbin 。而四者存放的文件一般如下: bin目录:bin为binary的简写主要放置一些系统的必备执行档例如:cat、cp、chmod df、dmesg、gzip、kill、ls、mkdir、more...
分类:系统相关   时间:2014-10-06 20:42:10    阅读次数:259
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...
分类:其他好文   时间:2014-10-06 19:32:50    阅读次数:173
leetcode - 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 devis...
分类:其他好文   时间:2014-10-06 18:43:20    阅读次数:201
leetcode - Binary Tree Zigzag Level Order Traversal
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 ...
分类:其他好文   时间:2014-10-06 16:46:00    阅读次数:165
leetcode - 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. /** * Definition for binary tree ...
分类:其他好文   时间:2014-10-06 16:08:40    阅读次数:181
leetcode - 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. /** * Definition for binary tree * struct TreeNode { ...
分类:其他好文   时间:2014-10-06 14:46:30    阅读次数:202
leetcode - 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. /** * Definition for binary tree * struct TreeNode {...
分类:其他好文   时间:2014-10-06 14:45:50    阅读次数:178
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!