文章
[Leetcode] Integer Break 分解整数最大乘积
IntegerBreak<blockquote<pGivenapositiveintegern,breakitintothesumofatleasttwopositiveintegersandmaximizetheproductofth
75. Sort Colors
题目:Givenanarraywithnobjectscoloredred,whiteorblue,sortthemsothatobjectsofthesamecolorareadjacent,withthecolorsintheorde
147. Insertion Sort List
注意新的list跟原来的list是不相连的,然后把各个状态的点记录好就行:<pre<codepublicListNodeinsertionSortList(ListNodehead){if(headnull||head.nextnull)r
179. Largest Number
这道题开始想容易陷入一个误区:我要怎么比较这两个单独的数,使得它们拼起来的结果最大呢?然而如果真的仔细比较这两个数最后得出一个结论,代码会很长,楼主已经试过了。。。后来转念一想,直接比较两个数拼成的结果不就好了,长度一样,所以省去了很多麻烦。程序如下:<pre<codepublicStr
[Leetcode] Generalized Abbreviation 列举单词缩写
GeneralizedAbbreviation<blockquote<pWriteafunctiontogeneratethegeneralizedabbreviationsofaword.</p<pExample:<br/Givenword
148. Sort List
题目:SortalinkedlistinO(nlogn)timeusingconstantspacecomplexity.解答:(对于discuss中第二个最优解的解释)根据时间复杂度的要求,很容易想到应该用mergesort的方法来做,那么就有两个步骤
[Leetcode] ZigZag Conversion 波浪形打印字符串
ZigZagConversion<blockquote<pThestring&34;PAYPALISHIRING&34;iswritteninazigzagpatternonagivennumberofrowslikethis:(youm
[Leetcode] Bulls and Cows 猜数字
BullsandCows<blockquote<pYouareplayingthefollowingBullsandCowsgamewithyourfriend:Youwritedownanumberandaskyourfriendt
[Leetcode] Paint Fence 栅栏涂色
PaintFence<blockquote<pThereisafencewithnposts,eachpostcanbepaintedwithoneofthekcolors.</p<pYouhavetopaintallthep
354. Russian Doll
典型的dp,注意点的程序中已经标出:<pre<codepublicclassSolution{//State:Sortenvelopes&39;width,fiismaximumnumberofenvelopesnumberienvelope
已加载文章中没有匹配内容,试试其他关键词或清空搜索。