码迷,mamicode.com
首页 >  
搜索关键字:cc150    ( 107个结果
CC150 19.2
19.2Designanalgorithmtofigureoutifsomeonehaswoninagameoftic-tac-toe.classTicTacToe { enumTic { X,O } //GivenTicTacToemap,wheterthaswonthegame. //Assumemapisanot-null3*3matrix,containingnonullelements. // //checkrow,checkcolumn,checkcorner //Thisisabrutefor..
分类:其他好文   时间:2014-12-10 14:26:06    阅读次数:187
CC150 19.4
19.4Writeamethodwhichfindsthemaximumoftwonumbers.Youshouldnotuseif-elseoranyothercomparisonoperator.intmax(inta,intb) { int[]temp={a,b}; //Ifa>b,(a-b)>>31willbe0...000000; //Else,itwillbe11111111..1; //Thus, intk=((a-b)>>31)&1; returntem..
分类:其他好文   时间:2014-12-10 14:22:58    阅读次数:174
CC150 9.5
9.5Givenasortedarrayofstringswhichisinterspersedwithemptystrings,writeamethodtofindthelocationofagivenstring.Example:find“ball”in[“at”,“”,“”,“”,“ball”,“”,“”,“car”,“”,“”,“dad”,“”,“”]willreturn4Example:find“ballcar”in[“at”,“”..
分类:其他好文   时间:2014-12-05 19:50:00    阅读次数:135
CC150 9.4
9.4Ifyouhavea2GBfilewithonestringperline,whichsortingalgorithmwouldyouusetosortthefileandwhy?Whatarethecommonsortingalgorithms?http://en.wikipedia.org/wiki/Sorting_algorithmMergesort,divideandconquerQuicksort,usingapivot.allnumbersbiggerthanpivotgoesoneside..
分类:其他好文   时间:2014-12-05 11:00:30    阅读次数:164
CC150 9.2
9.2Writeamethodtosortanarrayofstringssothatalltheanagramsarenexttoeachother.Useamap,thekeyissortedstring,valueislistofanagramsusingcharsinthekey.List<String>sortByAnagrams(List<String>strings) { Map<String,List<String>>map; for(Stri..
分类:其他好文   时间:2014-12-04 10:22:12    阅读次数:128
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.2
8.2ImaginearobotsittingontheupperlefthandcornerofanNxNgrid.Therobotcanonlymoveintwodirections:rightanddown.Howmanypossiblepathsaretherefortherobot?FOLLOWUPImaginecertainsquaresare“offlimits”,suchthattherobotcannotsteponthem.Designanalgorithmtogetallpossib..
分类:其他好文   时间:2014-12-01 10:16:04    阅读次数:118
107条   上一页 1 ... 5 6 7 8 9 ... 11 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!