题目:给定两个二进制字符串,返回相加的结果,也是二进制表示。主要就是考查进位如何操作,以及最后如果加完之后进位还是1的话那么不能漏了还要加1.跟之前有做过一题的类似。因为这题easy就是判断,所以直接贴代码了,感觉好长的样子。class Solution {public: string add...
分类:
其他好文 时间:
2014-11-09 00:58:42
阅读次数:
130
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.Solution: 1 /** 2 * Definition for binary tree 3 * .....
分类:
其他好文 时间:
2014-11-09 00:58:31
阅读次数:
213
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...
分类:
其他好文 时间:
2014-11-09 00:55:08
阅读次数:
250
Binary Tree Preorder TraversalGiven a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ ...
分类:
其他好文 时间:
2014-11-08 23:36:00
阅读次数:
202
原创性申明:
本文地址是 http://blog.csdn.net/zhujunxxxxx/article/details/40658925 转载请注明出处。作者联系邮箱 zhujunxxxxx@163.com
二叉排序树
(Binary Sort Tree)又称二叉查找树(Binary Search Tree),亦称二叉搜索树。
它或者是一棵空树;或者是具有下列性质的二叉树:
(1)若...
分类:
编程语言 时间:
2014-11-08 22:15:05
阅读次数:
211
1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(i...
分类:
其他好文 时间:
2014-11-08 21:58:27
阅读次数:
179
题意:
Given a binary tree, return the inorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3},
1
2
/
3
return [1,3,2].
Note: Recursive solution is trivial, could you do it iteratively?...
分类:
其他好文 时间:
2014-11-08 19:43:46
阅读次数:
188
Given a binary tree, print it vertically. The following example illustrates vertical order traversal. 1 / \ 2 3 / \ / \ 4 5 6 7 \ \ 8 9The output of p...
分类:
其他好文 时间:
2014-11-08 19:29:26
阅读次数:
212
题意:N个点,M条边。每条边连接两个点u,v,且有一个权值c,c非零即一。问能否将N个点形成一个生成树,并且这棵树的边权值和是一个fibonacii数。 (fibonacii数=1,2,3,5,8 .... )思路:若可以生成一棵树。则有最小生成树和最大生成树。假设已经生成了最小MST P 和最大M...
分类:
其他好文 时间:
2014-11-08 16:43:32
阅读次数:
181
#include #include class Node {public: Node* L; Node* R; int height; int data; Node(int val, Node* l = NULL, Node* r = NULL, int h = 0):...
分类:
其他好文 时间:
2014-11-08 16:39:27
阅读次数:
137