码迷,mamicode.com
首页 >  
搜索关键字:binary trees    ( 12390个结果)
uva 122 - Trees on the level(一棵看着书都写不利索的树……)
#include #include #include #include #include #include using namespace std; const int maxn = 1000; char s[maxn]; bool failed; vector ans; struct node { bool have_value; int v; node *left,*...
分类:其他好文   时间:2014-07-27 11:54:43    阅读次数:198
POJ - 3522 Slim Span (kruskal+枚举)
Description Given an undirected weighted graph G, you should find one of spanning trees specified as follows. The graph G is an ordered pair (V, E), where V is a set of vertices {v1, v2, …, vn}...
分类:其他好文   时间:2014-07-27 11:48:33    阅读次数:312
[LeetCode] Binary Tree Level Order Traversal
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example: Given binary tree {3...
分类:其他好文   时间:2014-07-26 14:03:16    阅读次数:174
Maximal Rectangle leetcode java
题目:Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.题解:这道题可以应用之前解过的Largetst Recta....
分类:编程语言   时间:2014-07-26 09:55:57    阅读次数:301
zoj 1453 Surround the Trees(凸包求周长)
链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=453Time Limit:2 Seconds Memory Limit:65536 KBThere are a lot of trees in an area. A peas...
分类:其他好文   时间:2014-07-26 00:23:16    阅读次数:351
Heap Sort (堆排序)
Heap sort is common in written exams.First of all, what is heap? Heap is a kind of data struct that can be seen as a complete binary tree. The objectt...
分类:其他好文   时间:2014-07-26 00:13:06    阅读次数:343
POJ1990 MooFest 树状数组(Binary Indexed Tree,BIT)
N头牛排成一列,每头牛的听力是Vi,每头牛的位置Pi,任意两头牛i,j相互交流时两头牛都至少需要发出声音的大小为max(Vi,Vj) * |Pi-Pj|,求这N头牛两两交流总共发出的声音大小是多少。N,V,P都是1-20000的范围。         这题首先对Vi从小到大进行排序,排序过后就可以依次计算i,将所有比Vi小的牛到i之间的距离之和乘以Vi得到Ri,然后累加Ri就是最终结果...
分类:其他好文   时间:2014-07-25 11:27:51    阅读次数:193
【LeetCode】【Python】Binary Tree Inorder Traversal
Given a binary tree, return the inorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 比较简单,就是转化成中序遍历即可,访问顺序是中序遍历左子树,根节点,中序遍历右子树 Python编程的时候需要注意,要在返回单一数字的时候加...
分类:编程语言   时间:2014-07-25 11:07:51    阅读次数:221
【leetcode刷题笔记】Maximal Rectangle
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.题解,很巧妙的一道题,对于一个0-1矩阵,它的每一行及以上都可以看...
分类:其他好文   时间:2014-07-25 10:53:01    阅读次数:292
[leetcode]Add Binary
Add BinaryGiven two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".算法思路:模拟二进制加法,跟十进制木有区别,将a,b转置(不转置的话,倒着...
分类:其他好文   时间:2014-07-24 22:57:23    阅读次数:216
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!