I think the official documentation gives you
the answer to this one (albeit in a fairly nonspecific way):This method is the
dynamic equivalent of the ...
分类:
其他好文 时间:
2014-05-14 03:31:06
阅读次数:
223
原题地址:http://oj.leetcode.com/problems/binary-tree-level-order-traversal/题意:二叉树的层序遍历的实现。解题思路:二叉树的层序遍历可以用bfs或者dfs来实现。这里使用的dfs实现,代码比较简洁。实际上,二叉树的先序遍历就是dfs实...
分类:
编程语言 时间:
2014-05-14 03:25:59
阅读次数:
428
Best Time to Buy and Sell StockSay you have an
array for which theithelement is the price of a given stock on dayi.If you were
only permitted to compl...
分类:
其他好文 时间:
2014-05-12 05:56:14
阅读次数:
315
A处理ab,处理cd。然后查找。比赛的时候用的DFS,爆栈了==vector >
V[2];void deal(int x,int y,vector > &V){ while(x>0&&y>0) {
V.push_back(make_pair(x,y)); i...
分类:
其他好文 时间:
2014-05-11 23:39:44
阅读次数:
436
题目链接:点击打开链接
题意比较明显,不赘述。
删除时可以把i-1转到根,把i+1转到根下
则i点就在 根右子树 的左子树,且只有i这一个 点
#include
#include
#include
#include
using namespace std;
#define N 300500
#define inf 10000000
#define L(x) tree[x].ch[0]
#d...
分类:
其他好文 时间:
2014-05-11 21:05:52
阅读次数:
365
题意:
给定2个操作
0、把区间的每个数sqrt
2、求和
因为每个数的sqrt次数很少,所以直接更新到底,用个标记表示是否更新完全(即区间内的数字只有0,1就不用再更新了)
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
#define N 1000...
分类:
其他好文 时间:
2014-05-11 21:02:45
阅读次数:
325
Given a set ofnon-overlappingintervals, insert
a new interval into the intervals (merge if necessary).You may assume that the
intervals were initially...
分类:
其他好文 时间:
2014-05-11 16:35:35
阅读次数:
224
Given an array of words and a length L, format
the text such that each line has exactly L characters and is fully (left and
right) justified.You shoul...
分类:
其他好文 时间:
2014-05-11 15:15:29
阅读次数:
287
这道题之前一直没敢做,没想到前天用递归一遍过了。。
当时为什么想着用递归,而不是dp呢,因为我想到达某个位置的情况有很多,即使从当前位置开始的搜索是已知的,但之前的状态是怎样的也无从得知啊,实话实说,我是不会用dp解这个。。
递归的思路就好说多了,从当前点开始,有上下左右四个位置可以探测,如果探测成功的话,要把当前的位置用其他符号标记出来,以免重复访问。实际上就是DFS嘛,只不过入口多一些。
...
分类:
其他好文 时间:
2014-05-11 14:20:56
阅读次数:
321
#ftp
#ljl
#!/usr/bin/perl
use strict;
use Net::FTP;
my $user = "anonymous";
my $passwd = "chinaunix@";
my $host = "ftp.freebsd.org";
my $ftp = Net::FTP->new("$host", Debug =>0)
or die "Can't connec...
分类:
其他好文 时间:
2014-05-11 13:23:26
阅读次数:
286