tree把每条边权是1的边断开,发现每个点离他最近的点个数就是他所在的连通块大小.开一个并查集,每次读到边权是0的边就合并.最后Ans?i??=size[findset(i)],size表示每个并查集根的sizeAns_i=size[findset(i)],sizeAns?i??=size[find...
分类:
其他好文 时间:
2016-01-02 22:36:51
阅读次数:
536
There are two sorted arraysnums1andnums2of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should...
分类:
其他好文 时间:
2016-01-02 22:29:36
阅读次数:
200
一、安装准备二、安装nginx安装之前,最好检查一下是否已经安装有nginx$ find -name nginx如果系统已经安装了nginx,那么就先卸载$ yum remove nginx首先进入/usr/local目录$ cd /usr/local从官网下载最新版的nginx$ wget htt...
分类:
其他好文 时间:
2016-01-02 20:27:05
阅读次数:
183
jquery的filter()函数和find()函数的区别:在jQuery中中众多的函数,使用起来非常的方便,同时有些函数在作用上非常的接近,于是也容易造成一定的误操作。filter()函数和find()函数同有筛选的作用,下面就介绍一下它们两者之间的区别。一.filter()函数:此函数用来筛选元...
分类:
Web程序 时间:
2016-01-02 16:30:49
阅读次数:
180
题目:Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). For example,S = "ADOBE...
Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.The update(i, val) function modifies nums by upda...
分类:
其他好文 时间:
2016-01-02 14:21:27
阅读次数:
204
strig=“what is your name”substring="name"str.endswith(suffix[,start[,end]])str.find(sub[,start[,end]])str.index(sub[,start[,end]])str.rfind(sub[,start...
分类:
其他好文 时间:
2016-01-02 10:29:42
阅读次数:
969
Suppose you are at a party withnpeople (labeled from0ton - 1) and among them, there may exist one celebrity. The definition of a celebrity is that all...
分类:
其他好文 时间:
2016-01-02 08:43:25
阅读次数:
141
Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. You may assum...
分类:
其他好文 时间:
2016-01-02 08:42:49
阅读次数:
341
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent
a number.
An example is the root-to-leaf path 1->2->3 which represents the number 123.
Find the tota...
分类:
其他好文 时间:
2016-01-01 19:07:40
阅读次数:
185