码迷,mamicode.com
首页 >  
搜索关键字:interview    ( 649个结果
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
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
LRU cache.
Seehttp://blog.csdn.net/hexinuaa/article/details/6630384Node<T> { Tdata; Node<T>next; Node<T>pre; } Node<T>swapToHead(Node<T>head,Node<T>n) { if(n==head) returnn; Node<T>temp=n.next; n.next=temp; if(temp!=null)tem..
分类:系统相关   时间:2014-12-06 11:31:27    阅读次数:302
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
A sudoku verifier
publicclassSudokuVerifier{ privatebooleanis1To9Row(int[][]a,intr){ int[]pos=newint[9]; for(inti=0;i<9;i++){ if(pos[a[r][i]]==1) returnfalse; pos[a[r][i]]=1; } for(inti:pos){ if(i==0) returnfalse; } returntrue; } priv..
分类:其他好文   时间:2014-12-04 10:24:30    阅读次数:151
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
649条   上一页 1 ... 49 50 51 52 53 ... 65 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!