码迷,mamicode.com
首页 >  
搜索关键字:cc150    ( 107个结果
CC150 20.11
20.11Imagineyouhaveasquarematrix,whereeachcellisfilledwitheitherblackorwhite.Designanalgorithmtofindthemaximumsubsquaresuchthatallfourbordersarefilledwithblackpixels.//Abruteforcesolution. //n*n //iteratefromnto1. //Forn,findallpossiblesubsquare EnumColor..
分类:其他好文   时间:2014-12-14 18:43:36    阅读次数:225
CC150 20.8
20.8GivenastringsandanarrayofsmallerstringsT,designamethodtosearchsforeachsmallstringinT.KMPBMFancymethod.
分类:其他好文   时间:2014-12-12 16:54:50    阅读次数:123
CC150 20.9
20.9Numbersarerandomlygeneratedandpassedtoamethod.Writeaprogramtofindandmaintainthemedianvalueasnewvaluesaregenerated.classMedianNum { //O(n) voidinsert(intn) { if(size==0) { head=newNode(n); media=head; } elseif(n<head.num) { NodenewHead=newNode(n); ne..
分类:其他好文   时间:2014-12-12 16:49:31    阅读次数:151
CC150 20.3
20.3Writeamethodtorandomlygenerateasetofmintegersfromanarrayofsizen.Eachelementmusthaveequalprobabilityofbeingchosen.//Similarto20.2 //Thisassumem<=n
分类:其他好文   时间:2014-12-11 10:36:40    阅读次数:132
CC150 19.11
19.11Designanalgorithmtofindallpairsofintegerswithinanarraywhichsumtoaspecifiedvalue. //Assumeaisnotnull. // //aisnotsorted. // //Option1isusingaset. List<Pair<Integer,Integer>>sumUpTo(int[]a,intsum) { //Option1 Map<Integer>set=newHashSet&..
分类:其他好文   时间:2014-12-11 10:36:22    阅读次数:168
CC150 20.1
20.1Writeafunctionthataddstwonumbers.Youshouldnotuse+oranyarithmeticoperators.//SorryIdon‘tknow.Ihatequestionslikethis.
分类:其他好文   时间:2014-12-11 10:35:54    阅读次数:133
CC150 20.2
20.2Writeamethodtoshuffleadeckofcards.Itmustbeaperfectshuffle-inotherwords,each52!permutationsofthedeckhastobeequallylikely.Assumethatyouaregivenarandomnumbergeneratorwhichisperfect.//Randomlygenerateaintkfrom1(inclusive)ton(inclusive). intrandom(intn); cl..
分类:其他好文   时间:2014-12-11 10:35:50    阅读次数:165
CC150 20.4
20.4Writeamethodtocountthenumberof2sbetween0andn.//Whatthismean? //Givenan. //for(inti=0->n) //{ //result+=numOf2In(i); //} //Thisispurelyamathproblem.
分类:其他好文   时间:2014-12-11 10:34:40    阅读次数:234
CC150 20.6
20.6Describeanalgorithmtofindthelargest1millionnumbersin1billionnumbers.Assumethatthecomputermemorycanholdallonebillionnumbers.//canholdallnumbers. //Cheating! //Doweknowthemaxormin? //Considerusingbitmap //If1billionnumbersalsospreadalot. //1.Hash-spliti..
分类:其他好文   时间:2014-12-11 10:32:53    阅读次数:136
CC150 19.1
//Seehttp://www.hawstein.com/posts/19.1.html //19.1Writeafunctiontoswapanumberinplacewithouttemporaryvariables. classCC19_1 { voidswap() { inta; intb; a=a+b; b=a-b; a=a-b; } //or voidswap() { inta; intb; a=a^b; b=a^b; a=a^b; } }
分类:其他好文   时间:2014-12-10 14:26:30    阅读次数:145
107条   上一页 1 ... 4 5 6 7 8 ... 11 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!