在使用Mac中使用终端,特别是连接多个SSH服务的时候,在窗口标签中显示当前所连接的主机就比较方便辨别。刚开始用的时候有一点问题,若ssh到server-a,终端标题会变更为server-a,但是exit后回到本机,标题依然显示server-a,搜索了一下刚好把这个问题解决了。达到这个效果的条..
分类:
其他好文 时间:
2014-11-27 08:05:17
阅读次数:
191
3.5ImplementaMyQueueclasswhichimplementsaqueueusingtwostacks.interfaceQueue<T>
{
enqueue(Tt);
Tdequeue();
}
classMyQueue<T>implementsQueue<T>
{
MyQueue()
{
//Initstackss1ands2;
...
}
//O(n)
enqueue(Tt)
{
while(!s2.isEmpty())
{
s1.push(s2..
分类:
其他好文 时间:
2014-11-27 08:05:14
阅读次数:
140
3.6Writeaprogramtosortastackinascendingorder.Youshouldnotmakeanyassumptionsabouthowthestackisimplemented.Thefollowingaretheonlyfunctionsthatshouldbeusedtowritethisprogram:push|pop|peek|isEmpty.interfaceStack<T>
{
push(Tt);
Tpop();
Tpeek();
booleanisEm..
分类:
其他好文 时间:
2014-11-27 08:02:46
阅读次数:
156
4.1Implementafunctiontocheckifatreeisbalanced.Forthepurposesofthisquestion,abalancedtreeisdefinedtobeatreesuchthatnotwoleafnodesdifferindistancefromtherootbymorethanone.Abalancedtree?http://en.wikipedia.org/wiki/Self-balancing_binary_search_treeIteratethetr..
分类:
其他好文 时间:
2014-11-27 08:03:52
阅读次数:
190
4.2Givenadirectedgraph,designanalgorithmtofindoutwhetherthereisaroutebetweentwonodes.Node
{
List<Node>neighbours;
}
booleanisConnected(Nodefrom,Nodeto)
{
Stack<Node>toVisit=initStack();
Set<Node>seen=initSet();
toVisit.push(from);
while..
分类:
其他好文 时间:
2014-11-27 08:05:32
阅读次数:
147
4.3Givenasorted(increasingorder)array,writeanalgorithmtocreateabinarytreewithminimalheight.[1,2,4,5,6]CreateaBTwithminheight.=>balancedtree.Nodebuild(intarray)
{
returnbuild(array,0,array.length-1,null);
}
O(logn)
privateNodebuild(int[]array,intfrom,int..
分类:
其他好文 时间:
2014-11-27 08:04:10
阅读次数:
189
4.4Givenabinarysearchtree,designanalgorithmwhichcreatesalinkedlistofallthenodesateachdepth(i.e.,ifyouhaveatreewithdepthD,you’llhaveDlinkedlists).List<List<Node>>build(Noderoot)
{
List<List<Node>>toReturn=initList();
build(root,0,toR..
分类:
其他好文 时间:
2014-11-27 08:02:53
阅读次数:
189
4.5Writeanalgorithmtofindthe‘next’node(i.e.,in-ordersuccessor)ofagivennodeinabinarysearchtreewhereeachnodehasalinktoitsparent.//BST.
classNode
{
Nodeparent;
Nodeleft;
Noderight;
}
Nodemin(Nodenode)
{
if(node==null)
returnnull;
while(node.left!=null)
nod..
分类:
其他好文 时间:
2014-11-27 08:01:56
阅读次数:
218
4.6Designanalgorithmandwritecodetofindthefirstcommonancestoroftwonodesinabinarytree.Avoidstoringadditionalnodesinadatastructure.NOTE:Thisisnotnecessarilyabinarysearchtree.BTNodefind(Noden,Nodea,Nodeb)
{
if(n==a||n==b)
{
returnn;
}
intnodeMatch=nodeMatch(a...
分类:
其他好文 时间:
2014-11-27 08:02:42
阅读次数:
180
a)在这里要提一下设计模式。设计模式是对一些特定场景实现代码的设计经验总结。在Java中有大概有23种吧,当然不是说让大家都熟练掌握,说实话,我现在也就了解那么几种,实际应用也没怎么使过。大家只需简单了解下就行。毕竟对自身编码会有好处的。
b)我们只要理解过滤器就很容易理解拦截器,无论是设计原理、设计模式还是实现方式上两者都是一样的,区别在于过滤器可以过滤一切东西,拦截器只能拦截action,因为我们只能在action上配置拦截器。
c)当我们编写代码时,要养成写注释的习惯。这个很重要,不只是为了让我们...
分类:
其他好文 时间:
2014-11-27 08:03:55
阅读次数:
181
近年来,P2P网贷呈现了迅猛发展的态势,作为互联网金融的重大突破,这一创新模式不仅获得了国家政策的支持和鼓励,更重要的是,通过不断的宣传和推广,越来越多普通老百姓也开始深入了解P2P网贷,包括三四线城市甚至农村的投资者,也对P2P网贷表现出浓厚的兴趣。
众所周知,要让三四线城市甚至农村的投资者也接受P2P网贷并非一件容易的事情,因为上述区域经济不如一二线城市发达,老百姓了...
分类:
其他好文 时间:
2014-11-27 08:02:33
阅读次数:
192
1023: [SHOI2008]cactus仙人掌图Time Limit:1 SecMemory Limit:162 MBSubmit:1141Solved:435[Submit][Status]Description如果某个无向连通图的任意一条边至多只出现在一条简单回路(simple cycle)...
分类:
其他好文 时间:
2014-11-27 08:00:03
阅读次数:
335
Tomcat由多个组件组成,那么Tomcat是怎么对他们的生命周期进行管理的么,这里将从Tomcat源码去分析其生命周期的实现;Bootstrape类为Tomcat的入口,所有的组件够通过实现Lifecycle接口来管理生命周期,Tomcat启动的时候只需调用Server容器的start(),然.....
分类:
其他好文 时间:
2014-11-27 08:02:10
阅读次数:
279
Given a 2D board containing'X'and'O', capture all regions surrounded by'X'.A region is captured by flipping all'O's into'X's in that surrounded region...
分类:
其他好文 时间:
2014-11-27 08:01:17
阅读次数:
160
Basic Tree TraversalDepth First Traversal:1. In order traversal----left, root, right----4,2,5,1,32. Pre order traversal-----root, left, right-----1,2,...
分类:
其他好文 时间:
2014-11-27 07:59:38
阅读次数:
232
Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below a...
分类:
其他好文 时间:
2014-11-27 08:00:27
阅读次数:
319
Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longes...
分类:
其他好文 时间:
2014-11-27 07:59:55
阅读次数:
184