当前位置:首页 » leetcode

leetcode

4
阅读

leetcode-104.+Maximum+Depth+of+Binary+Tree

leetcode-104.MaximumDepthofBinaryTree题目:Givenabinarytree,finditsmaximumdepth.Themaximumdepthisthenumberofnodesalongthelongestpathfromtherootnodedowntothefar...
来源 2016-12-27 09:50
4
阅读

leetcode-103.+Binary+Tree+Zigzag+Level+Order+Traversal

leetcode-103.BinaryTreeZigzagLevelOrderTraversal题目:Givenabinarytree,returnthezigzaglevelordertraversalofitsnodes’values.(ie,fromlefttoright,thenrighttoleft...
来源 2016-12-27 09:48
3
阅读

leetcode-102.+Binary+Tree+Level+Order+Traversal

leetcode-102.BinaryTreeLevelOrderTraversal题目:Givenabinarytree,returnthelevelordertraversalofitsnodes’values.(ie,fromlefttoright,levelbylevel).Forexample:Gi...
来源 2016-12-27 09:46
2
阅读

leetcode-101.+Symmetric+Tree

leetcode-101.SymmetricTree题目:Givenabinarytree,checkwhetheritisamirrorofitself(ie,symmetricarounditscenter).Forexample,thisbinarytree[1,2,2,3,4,4,3]issymmetr...
来源 2016-12-26 10:13
2
阅读

leetcode-100.+Same+Tree

leetcode-100.SameTree题目:Giventwobinarytrees,writeafunctiontocheckiftheyareequalornot.Twobinarytreesareconsideredequaliftheyarestructurallyidenticalandthenod...
来源 2016-12-26 10:12
4
阅读

leetcode-99.+Recover+Binary+Search+Tree

leetcode-99.RecoverBinarySearchTree题目Twoelementsofabinarysearchtree(BST)areswappedbymistake.Recoverthetreewithoutchangingitsstructure.Note:AsolutionusingO(n)...
来源 2016-12-26 10:11
4
阅读

leetcode-98.+Validate+Binary+Search+Tree

leetcode-98.ValidateBinarySearchTree题目:Givenabinarytree,determineifitisavalidbinarysearchtree(BST).AssumeaBSTisdefinedasfollows:Theleftsubtreeofanodecontain...
来源 2016-12-26 10:08
4
阅读

leetcode-97.+Interleaving+String

leetcode-97.InterleavingString题目:Givens1,s2,s3,findwhethers3isformedbytheinterleavingofs1ands2.Forexample,Given:s1=“aabcc”,s2=“dbbca”,Whens3=“aadbbcbca...
来源 2016-12-26 10:04
3
阅读

leetcode-96.+Unique+Binary+Search+Trees

leetcode-96.UniqueBinarySearchTrees题目:Givenn,howmanystructurallyuniqueBST’s(binarysearchtrees)thatstorevalues1…n?Forexample,Givenn=3,thereareatotalof5uniq...
来源 2016-12-26 09:58
5
阅读

leetcode-95.+Unique+Binary+Search+Trees+II

leetcode-95.UniqueBinarySearchTreesII题目:Givenanintegern,generateallstructurallyuniqueBST’s(binarysearchtrees)thatstorevalues1…n.Forexample,Givenn=3,yourpr...
来源 2016-12-26 09:53
5
阅读

leetcode-94.+Binary+Tree+Inorder+Traversal

leetcode-94.BinaryTreeInorderTraversal题目:Givenabinarytree,returntheinordertraversalofitsnodes’values.Forexample:Givenbinarytree[1,null,2,3],1\2/3return[1,3...
来源 2016-12-26 09:45
4
阅读

leetcode-93.+Restore+IP+Addresses

leetcode-93.RestoreIPAddresses题目:Givenastringcontainingonlydigits,restoreitbyreturningallpossiblevalidIPaddresscombinations.Forexample:Given“25525511135”,...
来源 2016-12-26 09:40
4
阅读

leetcode-92.+Reverse+Linked+List+II

leetcode-92.ReverseLinkedListII题目:Reversealinkedlistfrompositionmton.Doitin-placeandinone-pass.Forexample:Given1-2-3-4-5-NULL,m=2andn=4,return1-4-3-2-5-NULL...
来源 2016-12-26 09:36
3
阅读

leetcode-91.+Decode+Ways

leetcode-91.DecodeWays题目:AmessagecontaininglettersfromA-Zisbeingencodedtonumbersusingthefollowingmapping:‘A’-1‘B’-2…‘Z’-26Givenanencodedmessagecontai...
来源 2016-12-26 09:32
2
阅读

LeetCode题解(1)--Two+Sum

Givenanarrayofintegers,returnindicesofthetwonumberssuchthattheyadduptoaspecifictarget.Youmayassumethateachinputwouldhaveexactlyonesolution.example[code]Givennu...
来源 2016-12-25 15:58
3
阅读

leetcode之Find+All+Numbers+Disappeared+in+an+Array

很久没有刷题了,感觉大脑开始迟钝,所以决定重拾刷题的乐趣。一开始不要太难,选一些通过率高的题目做,然后就看到了这个题目。我有些吃惊,这个题我虽然知道两种解法,...
来源 2016-12-24 18:21
3
阅读

leetcode-89.+Gray+Code

leetcode-89.GrayCode题目:Thegraycodeisabinarynumeralsystemwheretwosuccessivevaluesdifferinonlyonebit.Givenanon-negativeintegernrepresentingthetotalnumberofbit...
来源 2016-12-22 11:07
5
阅读

leetcode-87.+Scramble+String

leetcode-87.ScrambleString题目:Givenastrings1,wemayrepresentitasabinarytreebypartitioningittotwonon-emptysubstringsrecursively.Belowisonepossiblerepresentatio...
来源 2016-12-22 11:04
3
阅读

leetcode-85.+Maximal+Rectangle

leetcode-85.MaximalRectangle题目:Givena2Dbinarymatrixfilledwith0’sand1’s,findthelargestrectanglecontainingonly1’sandreturnitsarea.Forexample,giventhefollow...
来源 2016-12-22 10:58
4
阅读

leetcode-84.+Largest+Rectangle+in+Histogram

leetcode-84.LargestRectangleinHistogram题目:Givennnon-negativeintegersrepresentingthehistogram’sbarheightwherethewidthofeachbaris1,findtheareaoflargestrectan...
来源 2016-12-22 10:46
5
阅读

[leetcode+javascript解题]Swap+Nodes+in+Pairs

leetcode24题“SwapNodesinPairs”描述如下:Givenalinkedlist,swapeverytwoadjacentnodesandreturnitshead.Forexample,Given1-2-3-4,youshouldreturnthelistas`2-1-4-3....
来源 2016-12-22 10:38
3
阅读

[leetcode+javascript解题]Generate+Parentheses

leetcode第22题”GenerateParenthese”描述如下:Givennpairsofparentheses,writeafunctiontogenerateallcombinationsofwell-formedparentheses.Forexample,givenn=3,asol...
来源 2016-12-21 21:30
3
阅读

[leetcode+javascript解题]Valid+Parentheses

leetcode20题ValidParentheses描述如下Givenastringcontainingjustthecharacters'(',')','{','}','['and']',determineiftheinputstringisvalid.Thebracketsmustcloseinthe...
来源 2016-12-21 19:41
5
阅读

LeetCode+7.+Reverse+Integer+题解

题目:Reversedigitsofaninteger.Example1:x=123,return321Example2:x=-123,return-321分析:很简单的一道题目,但是想AC还是要注意一些细节。。在分离出每一位数字后,...
来源 2016-12-21 15:38
6
阅读

[leetcode+javascript解题]Letter+Combinations+of+a+Phone+Number

leetcode的17题”LetterCombinationsofaPhoneNumber”描述如下:Givenadigitstring,returnallpossiblelettercombinationsthatthenumbercouldrepresent.Amappingofdigittol...
来源 2016-12-20 21:05