分割后长度相等,就是参数麻烦,p,先序的起始点, ib,ie 终须的结束和开始。 1 /** 2 * Definition for binary tree 3 * public class TreeNode { 4 * int val; 5 * TreeNode left;...
分类:
其他好文 时间:
2014-07-23 22:10:37
阅读次数:
211
今天温习树状数组,果然忘记了好多,树状数组求逆序数,值得注意这道题所有的数都是0-n-1的,所以在求最小的时候不用每个数顺序在计算一遍,我已开始就是把每个顺序又计算了一遍,果断超时了。第i个数拿到后面去,逆序数会减少a[i]-1,同时会增加n-a[i]
#include
#include
using namespace std;
int a[5005],tree[5005],n;
int low...
分类:
其他好文 时间:
2014-07-23 21:00:35
阅读次数:
186
style="padding-bottom: 0px; line-height: 1.5; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: 宋体, Arial; font-size: 14px; padding-top...
分类:
系统相关 时间:
2014-07-23 20:34:05
阅读次数:
288
void build(int l, int r, int n) //建树
{
int mid;
tree[n].l = l;
tree[n].r = r;
if(l==r)
{
tree[n].sum = h[l];
return ;
}
mid = (l+r)>>1;
build(l, mid, 2*n);
build(mid+1, r, 2*n+1);
tree[n].sum = tree[2*n].sum + tree[2*n+1].sum;
}...
分类:
其他好文 时间:
2014-07-23 18:11:36
阅读次数:
282
介绍还有一种平衡二叉树:红黑树(Red Black Tree),红黑树由Rudolf Bayer于1972年发明,当时被称为平衡二叉B树(symmetric binary B-trees),1978年被Leonidas J. Guibas和Robert Sedgewick改成一个比較摩登的名字:红黑...
分类:
其他好文 时间:
2014-07-23 15:16:46
阅读次数:
375
Given a strings1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation...
分类:
其他好文 时间:
2014-07-23 15:06:06
阅读次数:
320
今天在做项目开发时遇到这么一个错误,完整的错误提示信息如下:java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tony.timepicker/com.tony.timepicker.MainActivity}...
分类:
移动开发 时间:
2014-07-23 14:55:57
阅读次数:
328
#div1{
width:100px;
height:150px;
background:red;
position:absolute;
right:0;
bottom:0;
}
window.onscroll=function (){
var oDiv=document.getElementById('div1');
var s...
分类:
Web程序 时间:
2014-07-23 13:33:26
阅读次数:
216
#div1{
width:100px;
height:150px;
background:red;
position:absolute;
right:0;
bottom:0;
}
window.onscroll=function (){
var oDiv=document.getElementById('div1');
var s...
分类:
Web程序 时间:
2014-07-23 13:33:17
阅读次数:
286
题目大意:
给出一棵树,树上每个节点都有权值,然后有两个操作。
1 x val 在结点x上加上一个值val,x的儿子加上 -val,x的儿子的儿子加上 - (-val),以此类推。
2 x 问x节点的值。
思路分析:
每个节点上加值都是给自己的儿子节点加,而且这个是颗树。
比如样例上的,如果你给node 1加一个值,那么五个节点都加。
再给node 2加个值,2的儿子节点也加...
分类:
其他好文 时间:
2014-07-23 13:19:26
阅读次数:
272