E-COM-NET
首页
在线工具
Layui镜像站
SUI文档
联系我们
推荐频道
Java
PHP
C++
C
C#
Python
Ruby
go语言
Scala
Servlet
Vue
MySQL
NoSQL
Redis
CSS
Oracle
SQL Server
DB2
HBase
Http
HTML5
Spring
Ajax
Jquery
JavaScript
Json
XML
NodeJs
mybatis
Hibernate
算法
设计模式
shell
数据结构
大数据
JS
消息中间件
正则表达式
Tomcat
SQL
Nginx
Shiro
Maven
Linux
leetCode笔记
LeetCode笔记
:167. Two Sum II - Input array is sorted
问题:Givenanarrayofintegersthatisalreadysortedinascendingorder,findtwonumberssuchthattheyadduptoaspecifictargetnumber.ThefunctiontwoSumshouldreturnindicesofthetwonumberssuchthattheyadduptothetarget,wher
Cloudox_
·
2017-01-04 09:34
LeetCode
LeetCode笔记
LeetCode笔记
:6. ZigZag Conversion
问题:Thestring“PAYPALISHIRING”iswritteninazigzagpatternonagivennumberofrowslikethis:(youmaywanttodisplaythispatterninafixedfontforbetterlegibility)PAHNAPLSIIGYIRAndthenreadlinebyline:“PAHNAPLSIIGYIR”Wri
Cloudox_
·
2016-12-16 10:11
LeetCode
LeetCode笔记
LeetCode笔记
:190. Reverse Bits
问题:Reversebitsofagiven32bitsunsignedinteger.Forexample,giveninput43261596(representedinbinaryas00000010100101000001111010011100),return964176192(representedinbinaryas00111001011110000010100101000000).
Cloudox_
·
2016-12-06 09:54
leetcode
LeetCode
LeetCode笔记
LeetCode笔记
:396. Rotate Function
问题:GivenanarrayofintegersAandletntobeitslength.AssumeBktobeanarrayobtainedbyrotatingthearrayAkpositionsclock-wise,wedefinea“rotationfunction”FonAasfollow:F(k)=0*Bk[0]+1*Bk[1]+…+(n-1)*Bk[n-1].Calculate
Cloudox_
·
2016-12-05 09:32
leetcode
LeetCode
LeetCode笔记
LeetCode笔记
:400. Nth Digit
问题:Findthenthdigitoftheinfiniteintegersequence1,2,3,4,5,6,7,8,9,10,11,…Note:nispositiveandwillfitwithintherangeofa32-bitsignedinteger(nreduce+num*i){lastNum=lastNum+num;reduce=reduce+num*i;num=num*10;
Cloudox_
·
2016-12-01 14:19
LeetCode
LeetCode笔记
LeetCode笔记
:203. Remove Linked List Elements
问题:Removeallelementsfromalinkedlistofintegersthathavevalueval.ExampleGiven:1–>2–>6–>3–>4–>5–>6,val=6Return:1–>2–>3–>4–>5大意:移除链表中素有值为val的元素。例子:给出:1–>2–>6–>3–>4–>5–>6,val=6返回:1–>2–>3–>4–>5思路:这道题没什么特殊的,遍
Cloudox_
·
2016-11-30 10:44
leetcode
LeetCode
LeetCode笔记
LeetCode笔记
:234. Palindrome Linked List
问题:Givenasinglylinkedlist,determineifitisapalindrome.Followup:CouldyoudoitinO(n)timeandO(1)space?大意:给出一个单链表,判断它是否是回文。进阶:你能在O(n)的时间复杂度和O(1)的空间复杂度下来做吗?思路:回文的意思就是正着读反着读都是一样的。这道题我使用简单的思路,一个个遍历链表节点来倒序组成一个新
Cloudox_
·
2016-11-25 09:53
leetcode
LeetCode
LeetCode笔记
LeetCode笔记
:88. Merge Sorted Array
问题:Giventwosortedintegerarraysnums1andnums2,mergenums2intonums1asonesortedarray.Note:Youmayassumethatnums1hasenoughspace(sizethatisgreaterorequaltom+n)toholdadditionalelementsfromnums2.Thenumberofelem
Cloudox_
·
2016-11-24 14:01
LeetCode
LeetCode笔记
LeetCode笔记
:459. Repeated Substring Pattern
问题:Givenanon-emptystringcheckifitcanbeconstructedbytakingasubstringofitandappendingmultiplecopiesofthesubstringtogether.YoumayassumethegivenstringconsistsoflowercaseEnglishlettersonlyanditslengthwilln
Cloudox_
·
2016-11-20 14:31
LeetCode
LeetCode笔记
LeetCode笔记
:455. Assign Cookies
问题:Assumeyouareanawesomeparentandwanttogiveyourchildrensomecookies.But,youshouldgiveeachchildatmostonecookie.Eachchildihasagreedfactorgi,whichistheminimumsizeofacookiethatthechildwillbecontentwith;and
Cloudox_
·
2016-11-19 19:24
LeetCode
LeetCode笔记
LeetCode笔记
:38. Count and Say
问题:Thecount-and-saysequenceisthesequenceofintegersbeginningasfollows:1,11,21,1211,111221,…1isreadoffas“one1”or11.11isreadoffas“two1s”or21.21isreadoffas“one2,thenone1”or1211.Givenanintegern,generatethe
Cloudox_
·
2016-11-16 11:23
leetcode
LeetCode
LeetCode笔记
LeetCode笔记
:111. Minimum Depth of Binary Tree
问题:Givenabinarytree,finditsminimumdepth.Theminimumdepthisthenumberofnodesalongtheshortestpathfromtherootnodedowntothenearestleafnode.大意:给出一个二叉树,找到他最小的深度。最小的深度是指从根节点到叶子节点距离最短的节点数。思路:这道题要找到最短的深度,个人认为更应该
Cloudox_
·
2016-11-15 09:10
leetcode
LeetCode
LeetCode笔记
LeetCode笔记
:112. Path Sum
问题:Givenabinarytreeandasum,determineifthetreehasaroot-to-leafpathsuchthataddingupallthevaluesalongthepathequalsthegivensum.Forexample:Giventhebelowbinarytreeandsum=22,returntrue,asthereexistaroot-to-l
Cloudox_
·
2016-11-11 09:00
LeetCode
LeetCode笔记
:299. Bulls and Cows
问题:YouareplayingthefollowingBullsandCowsgamewithyourfriend:Youwritedownanumberandaskyourfriendtoguesswhatthenumberis.Eachtimeyourfriendmakesaguess,youprovideahintthatindicateshowmanydigitsinsaidguessm
Cloudox_
·
2016-11-10 10:00
LeetCode
LeetCode笔记
:374. Guess Number Higher or Lower
问题:WeareplayingtheGuessGame.Thegameisasfollows:Ipickanumberfrom1ton.YouhavetoguesswhichnumberIpicked.Everytimeyouguesswrong,I’lltellyouwhetherthenumberishigherorlower.Youcallapre-definedAPIguess(intnu
Cloudox_
·
2016-11-09 10:00
LeetCode
LeetCode笔记
:438. Find All Anagrams in a String
问题:Givenastringsandanon-emptystringp,findallthestartindicesofp’sanagramsins.StringsconsistsoflowercaseEnglishlettersonlyandthelengthofbothstringssandpwillnotbelargerthan20,100.Theorderofoutputdoesnotm
Cloudox_
·
2016-11-08 11:00
LeetCode
LeetCode笔记
:257. Binary Tree Paths
问题:Givenabinarytree,returnallroot-to-leafpaths.Forexample,giventhefollowingbinarytree:1/\23\5Allroot-to-leafpathsare:[“1->2->5”,“1->3”]大意:给出一个二叉树,返回所有从根节点到叶子节点的路径。比如给出下面这个二叉树:1/\23\5所有从根节点到叶子节点的路径为:[“
Cloudox_
·
2016-11-07 11:00
LeetCode
LeetCode笔记
:9. Palindrome Number
问题:Determinewhetheranintegerisapalindrome.Dothiswithoutextraspace.大意:判断一个整数是否是回文。不使用额外的空间来完成。思路:这道题目很简单,只有一句话,不要要求不使用额外空间,一般来说不使用额外空间的意思是不使用复杂度为O(n)的额外空间,新建一些字符串、整型值之类的还是可以的。回文的意思是从左到右读和从右到左读数字是一样的,比如
Cloudox_
·
2016-11-04 09:00
LeetCode
LeetCode笔记
:437. Path Sum III
问题:Youaregivenabinarytreeinwhicheachnodecontainsanintegervalue.Findthenumberofpathsthatsumtoagivenvalue.Thepathdoesnotneedtostartorendattherootoraleaf,butitmustgodownwards(travelingonlyfromparentnodes
Cloudox_
·
2016-11-03 10:17
LeetCode
LeetCode笔记
LeetCode笔记
:437. Path Sum III
问题:Youaregivenabinarytreeinwhicheachnodecontainsanintegervalue.Findthenumberofpathsthatsumtoagivenvalue.Thepathdoesnotneedtostartorendattherootoraleaf,butitmustgodownwards(travelingonlyfromparentnodes
Cloudox_
·
2016-11-03 10:00
LeetCode
LeetCode笔记
:441. Arranging Coins
问题:Youhaveatotalofncoinsthatyouwanttoforminastaircaseshape,whereeveryk-throwmusthaveexactlykcoins.Givenn,findthetotalnumberoffullstaircaserowsthatcanbeformed.nisanon-negativeintegerandfitswithintheran
Cloudox_
·
2016-11-02 10:14
LeetCode
LeetCode笔记
LeetCode笔记
:441. Arranging Coins
问题:Youhaveatotalofncoinsthatyouwanttoforminastaircaseshape,whereeveryk-throwmusthaveexactlykcoins.Givenn,findthetotalnumberoffullstaircaserowsthatcanbeformed.nisanon-negativeintegerandfitswithintheran
Cloudox_
·
2016-11-02 10:00
LeetCode
LeetCode笔记
:412. Fizz Buzz
问题:Writeaprogramthatoutputsthestringrepresentationofnumbersfrom1ton.Butformultiplesofthreeitshouldoutput“Fizz”insteadofthenumberandforthemultiplesoffiveoutput“Buzz”.Fornumberswhicharemultiplesofbothth
Cloudox_
·
2016-11-02 08:20
leetcode
LeetCode
LeetCode笔记
LeetCode笔记
:412. Fizz Buzz
问题:Writeaprogramthatoutputsthestringrepresentationofnumbersfrom1ton.Butformultiplesofthreeitshouldoutput“Fizz”insteadofthenumberandforthemultiplesoffiveoutput“Buzz”.Fornumberswhicharemultiplesofbothth
Cloudox_
·
2016-11-02 08:00
LeetCode
LeetCode笔记
:119. Pascal's Triangle II
问题:Givenanindexk,returnthekthrowofthePascal’striangle.Forexample,givenk=3,Return[1,3,3,1].Note:CouldyouoptimizeyouralgorithmtouseonlyO(k)extraspace?大意:给出一个序号k,返回杨辉三角形的第k行。比如给出k=3,返回[1,3,3,1]。注意:你能不能让你
Cloudox_
·
2016-11-01 09:00
LeetCode
LeetCode笔记
:172. Factorial Trailing Zeroes
问题:Givenanintegern,returnthenumberoftrailingzeroesinn!.Note:Yoursolutionshouldbeinlogarithmictimecomplexity.大意:给出一个整数n,返回n!后面0的个数。注意:你的算法时间复杂度要是logn以内。思路:这道题的要求是计算n的阶乘后面0的个数,而且要求算法时间复杂度为logn,那么就绝对不是要人
Cloudox_
·
2016-10-31 09:56
leetcode
LeetCode
LeetCode笔记
LeetCode笔记
:172. Factorial Trailing Zeroes
问题:Givenanintegern,returnthenumberoftrailingzeroesinn!.Note:Yoursolutionshouldbeinlogarithmictimecomplexity.大意:给出一个整数n,返回n!后面0的个数。注意:你的算法时间复杂度要是logn以内。思路:这道题的要求是计算n的阶乘后面0的个数,而且要求算法时间复杂度为logn,那么就绝对不是要人
Cloudox_
·
2016-10-31 09:00
LeetCode
LeetCode笔记
:232. Implement Queue using Stacks
问题:Implementthefollowingoperationsofaqueueusingstacks.push(x)–Pushelementxtothebackofqueue.pop()–Removestheelementfrominfrontofqueue.peek()–Getthefrontelement.empty()–Returnwhetherthequeueisempty.Note
Cloudox_
·
2016-10-28 15:07
leetcode
LeetCode
LeetCode笔记
LeetCode笔记
:232. Implement Queue using Stacks
问题:Implementthefollowingoperationsofaqueueusingstacks.push(x)–Pushelementxtothebackofqueue.pop()–Removestheelementfrominfrontofqueue.peek()–Getthefrontelement.empty()–Returnwhetherthequeueisempty.Note
Cloudox_
·
2016-10-28 15:07
leetcode
LeetCode
LeetCode笔记
LeetCode笔记
:232. Implement Queue using Stacks
问题:Implementthefollowingoperationsofaqueueusingstacks.push(x)–Pushelementxtothebackofqueue.pop()–Removestheelementfrominfrontofqueue.peek()–Getthefrontelement.empty()–Returnwhetherthequeueisempty.Note
Cloudox_
·
2016-10-28 15:00
LeetCode
LeetCode笔记
:26. Remove Duplicates from Sorted Array
问题:Givenasortedarray,removetheduplicatesinplacesuchthateachelementappearonlyonceandreturnthenewlength.Donotallocateextraspaceforanotherarray,youmustdothisinplacewithconstantmemory.Forexample,Giveninpu
Cloudox_
·
2016-10-27 09:24
leetcode
LeetCode
LeetCode笔记
LeetCode笔记
:26. Remove Duplicates from Sorted Array
问题:Givenasortedarray,removetheduplicatesinplacesuchthateachelementappearonlyonceandreturnthenewlength.Donotallocateextraspaceforanotherarray,youmustdothisinplacewithconstantmemory.Forexample,Giveninpu
Cloudox_
·
2016-10-27 09:24
leetcode
LeetCode
LeetCode笔记
LeetCode笔记
:26. Remove Duplicates from Sorted Array
问题:Givenasortedarray,removetheduplicatesinplacesuchthateachelementappearonlyonceandreturnthenewlength.Donotallocateextraspaceforanotherarray,youmustdothisinplacewithconstantmemory.Forexample,Giveninpu
Cloudox_
·
2016-10-27 09:00
LeetCode
LeetCode笔记
:110. Balanced Binary Tree
问题:Givenabinarytree,determineifitisheight-balanced.Forthisproblem,aheight-balancedbinarytreeisdefinedasabinarytreeinwhichthedepthofthetwosubtreesofeverynodeneverdifferbymorethan1.大意:给出一个二叉树,判断它高度是不是平衡
Cloudox_
·
2016-10-26 14:00
LeetCode
LeetCode笔记
:102. Binary Tree Level Order Traversal
问题:Givenabinarytree,returnthelevelordertraversalofitsnodes’values.(ie,fromlefttoright,levelbylevel).Forexample:Givenbinarytree[3,9,20,null,null,15,7],3/\920/\157returnitslevelordertraversalas:[[3],[9,
Cloudox_
·
2016-10-25 09:00
LeetCode
LeetCode笔记
:118. Pascal's Triangle
问题:GivennumRows,generatethefirstnumRowsofPascal’striangle.Forexample,givennumRows=5,Return[[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]]大意:给出一个行数,生出对应行数的杨辉三角形。比如,给出行数=5。返回[[1],[1,1],[1,2,1],[1,3,3,1],[1,4,
Cloudox_
·
2016-10-24 09:00
LeetCode
LeetCode笔记
:101. Symmetric Tree
问题:Givenabinarytree,checkwhetheritisamirrorofitself(ie,symmetricarounditscenter).Forexample,thisbinarytree[1,2,2,3,4,4,3]issymmetric:1/\22/\/\3443Butthefollowing[1,2,2,null,3,null,3]isnot:1/\22\\33Not
Cloudox_
·
2016-10-20 09:00
LeetCode
LeetCode笔记
:27. Remove Element
问题:Givenanarrayandavalue,removeallinstancesofthatvalueinplaceandreturnthenewlength.Donotallocateextraspaceforanotherarray,youmustdothisinplacewithconstantmemory.Theorderofelementscanbechanged.Itdoesn’
Cloudox_
·
2016-10-19 09:00
LeetCode
LeetCode笔记
:66. Plus One
问题:Givenanon-negativenumberrepresentedasanarrayofdigits,plusonetothenumber.Thedigitsarestoredsuchthatthemostsignificantdigitisattheheadofthelist.大意:给出一个非负数的代表数字的数组,给这个“数字”加一。这个数字的存储形式为最高位的数再数组的最前端。思路:
Cloudox_
·
2016-10-18 09:00
LeetCode
LeetCode笔记
:141. Linked List Cycle
问题:Givenalinkedlist,determineifithasacycleinit.Followup:Canyousolveitwithoutusingextraspace?大意:给出一个链表,判断它有没有回环。进阶:你能不能不用额外的空间来解决?思路:这道题我利用Java中Set集合的特性,即集合中不允许出现相同的对象。我们遍历链表,边遍历边把每个节点放入一个Set集合中,并且每次都判
Cloudox_
·
2016-10-12 10:00
LeetCode
LeetCode笔记
:107. Binary Tree Level Order Traversal II
问题:Givenabinarytree,returnthebottom-uplevelordertraversalofitsnodes’values.(ie,fromlefttoright,levelbylevelfromleaftoroot).Forexample:Givenbinarytree[3,9,20,null,null,15,7],3/\920/\157returnitsbottom-
Cloudox_
·
2016-10-11 10:00
LeetCode
LeetCode笔记
:415. Add Strings
问题:Giventwonon-negativenumbersnum1andnum2representedasstring,returnthesumofnum1andnum2.Note:1、Thelengthofbothnum1andnum2is=0||j>=0){ intn1=i>=0?num1.charAt(i)-'0':0; intn2=j>=0?num2.charAt(j)-'0':0; i
Cloudox_
·
2016-10-10 09:00
LeetCode
LeetCode笔记
:235. Lowest Common Ancestor of a Binary Search Tree
问题:Givenabinarysearchtree(BST),findthelowestcommonancestor(LCA)oftwogivennodesintheBST.AccordingtothedefinitionofLCAonWikipedia:“ThelowestcommonancestorisdefinedbetweentwonodesvandwasthelowestnodeinTt
Cloudox_
·
2016-09-27 10:00
LeetCode
LeetCode笔记
:121. Best Time to Buy and Sell Stock
问题:Sayyouhaveanarrayforwhichtheithelementisthepriceofagivenstockondayi.Ifyouwereonlypermittedtocompleteatmostonetransaction(ie,buyoneandselloneshareofthestock),designanalgorithmtofindthemaximumprofit.
Cloudox_
·
2016-09-26 10:00
LeetCode
LeetCode笔记
:404. Sum of Left Leaves
问题:Findthesumofallleftleavesinagivenbinarytree.Example:3 /\ 920 /\ 157 Therearetwoleftleavesinthebinarytree,withvalues9and15respectively.Return24.大意:计算一个二叉树中所有左叶子节点的和例子:3 /\ 920 /\ 157 在这个二叉树中有两个左叶子节点
Cloudox_
·
2016-09-26 09:00
LeetCode
LeetCode笔记
:70. Climbing Stairs
问题:Youareclimbingastaircase.Ittakesnstepstoreachtothetop.Eachtimeyoucaneitherclimb1or2steps.Inhowmanydistinctwayscanyouclimbtothetop?大意:你在爬一个楼梯。需要n节楼梯到达顶部。每次你可以爬一节或者两节楼梯。你总共有多少种爬到顶部的方法?思路:总觉得这个题目小时候做过
Cloudox_
·
2016-09-23 09:00
LeetCode
LeetCode笔记
:263. Ugly Number
问题:Writeaprogramtocheckwhetheragivennumberisanuglynumber.Uglynumbersarepositivenumberswhoseprimefactorsonlyinclude2,3,5.Forexample,6,8areuglywhile14isnotuglysinceitincludesanotherprimefactor7.Notethat
Cloudox_
·
2016-09-22 09:00
LeetCode
LeetCode笔记
:350. Intersection of Two Arrays II
问题:Giventwoarrays,writeafunctiontocomputetheirintersection.Example:Givennums1=[1,2,2,1],nums2=[2,2],return[2,2].Note:Eachelementintheresultshouldappearasmanytimesasitshowsinbotharrays.Theresultcanbein
Cloudox_
·
2016-09-14 14:00
LeetCode
LeetCode笔记
:387. First Unique Character in a String
问题:Givenastring,findthefirstnon-repeatingcharacterinitandreturnit’sindex.Ifitdoesn’texist,return-1.Examples:s=“leetcode”return0.s=“loveleetcode”,return2.Note:Youmayassumethestringcontainonlylowercasel
Cloudox_
·
2016-09-13 09:00
LeetCode
LeetCode笔记
:136. Single Number
问题:Givenanarrayofintegers,everyelementappearstwiceexceptforone.Findthatsingleone.Note:Youralgorithmshouldhavealinearruntimecomplexity.Couldyouimplementitwithoutusingextramemory?大意:给出一个整数数组,其中每个元素都出现了两
Cloudox_
·
2016-09-07 14:00
LeetCode
上一页
8
9
10
11
12
13
14
15
下一页
按字母分类:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
其他