码迷,mamicode.com
首页 >  
搜索关键字:interview    ( 649个结果
CC150 9.1
9.1Youaregiventwosortedarrays,AandB,andAhasalargeenoughbufferattheendtoholdB.WriteamethodtomergeBintoAinsortedorder.Option1.CreateanextrabigarrayC.iteratebothAandB.returnC.O(m+n)Option2.AssumeAisbigenough.IterateAandBstartingfromend.PutmaxvaluetotheendofA.i..
分类:其他好文   时间:2014-12-04 06:30:19    阅读次数:118
CC150 8.6
8.6Implementthe“paintfill”functionthatonemightseeonmanyp_w_picpatheditingprograms.Thatis,givenascreen(representedbya2dimensionalarrayofColors),apoint,andanewcolor,fillinthesurroundingareauntilyouhitaborderofthatcolor.interfacePanter { } classPos { intx, ..
分类:其他好文   时间:2014-12-02 12:00:20    阅读次数:116
CC150 8.4
8.4Writeamethodtocomputeallpermutationsofastring.ThisisaverysimilarquestiontoCC8.3 staticCollection<String>permutations(Strings) { if(s==null||s.isEmpty()) returnCollections.emptyList(); if(s.length()==1) returnCollections.singletonList..
分类:其他好文   时间:2014-12-01 16:14:11    阅读次数:165
CC150 8.3
8.3Writeamethodthatreturnsallsubsetsofaset.powerSet(i)= [powerSet(i-1)]*ITEMi+//Addnewitemintoeachexistingset [pwerSet(i-1)]+//Existingset ITEMi//singlenewitem. powerSet(1)=ITEM1. <T>Set<Set<T>>powerSet(Set<T>set) { if(set==null||se..
分类:其他好文   时间:2014-12-01 16:14:01    阅读次数:147
CC150 8.3
8.3Writeamethodthatreturnsallsubsetsofaset.powerSet(i)= [powerSet(i-1)]*ITEMi+//Addnewitemintoeachexistingset [pwerSet(i-1)]+//Existingset ITEMi//singlenewitem. powerSet(1)=ITEM1. <T>Set<Set<T>>powerSet(Set<T>set) { if(set==null||se..
分类:其他好文   时间:2014-12-01 10:16:15    阅读次数:146
CC150 8.2
8.2ImaginearobotsittingontheupperlefthandcornerofanNxNgrid.Therobotcanonlymoveintwodirections:rightanddown.Howmanypossiblepathsaretherefortherobot?FOLLOWUPImaginecertainsquaresare“offlimits”,suchthattherobotcannotsteponthem.Designanalgorithmtogetallpossib..
分类:其他好文   时间:2014-12-01 10:16:04    阅读次数:118
CC150 8.1
8.1WriteamethodtogeneratethenthFibonaccinumber.classFibonacci() { voidinit() { a=0; b=1; } intnext() { inttoReturn=a+b; a=b; b=toReturn; returntoReturn; } } { Fibonaccifibo=init(); for(n) { toReturn=fibo.next(); } returntoReturn; } fibonacci(intn) { if(..
分类:其他好文   时间:2014-11-28 10:30:25    阅读次数:149
CC150 4.7
4.7Youhavetwoverylargebinarytrees:T1,withmillionsofnodes,andT2,withhundredsofnodes.CreateanalgorithmtodecideifT2isasubtreeofT1.//Itwilliteratemaintree(millions)nodes. //Toobad. booleanisSubTree(Nodemain,Nodesub) { if(main==null) returnnull; if(main==sub) r..
分类:其他好文   时间:2014-11-28 10:30:24    阅读次数:157
CC150 3.5
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
CC150 3.6
3.6Writeaprogramtosortastackinascendingorder.Youshouldnotmakeanyassumptionsabouthowthestackisimplemented.Thefollowingaretheonlyfunctionsthatshouldbeusedtowritethisprogram:push|pop|peek|isEmpty.interfaceStack<T> { push(Tt); Tpop(); Tpeek(); booleanisEm..
分类:其他好文   时间:2014-11-27 08:02:46    阅读次数:156
649条   上一页 1 ... 50 51 52 53 54 ... 65 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!