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笔记
:83. Remove Duplicates from Sorted List
问题:Givenasortedlinkedlist,deleteallduplicatessuchthateachelementappearonlyonce.Forexample,Given1->1->2,return1->2.Given1->1->2->3->3,return1->2->3.大意:给出一个排好序的链表,删除所有的重复的数字,让每个元素只出现一次。比如:给出1->1->2,返回1-
Cloudox_
·
2020-02-21 20:55
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;ints
Cloudox_
·
2020-02-21 12:52
LeetCode笔记
:503. Next Greater Element II
问题:Givenacirculararray(thenextelementofthelastelementisthefirstelementofthearray),printtheNextGreaterNumberforeveryelement.TheNextGreaterNumberofanumberxisthefirstgreaternumbertoitstraversing-ordernex
Cloudox_
·
2020-02-21 05:56
LeetCode笔记
-0004-寻找两个有序数组的中位数
题目信息给定两个大小为m和n的有序数组nums1和nums2。请你找出这两个有序数组的中位数,并且要求算法的时间复杂度为O(log(m+n))。你可以假设nums1和nums2不会同时为空。示例1:nums1=[1,3]nums2=[2]则中位数是2.0示例2:nums1=[1,2]nums2=[3,4]则中位数是(2+3)/2=2.5来源:力扣(LeetCode)链接:https://leetc
dragonMen
·
2020-02-19 02:06
LeetCode笔记
:338. Counting Bits
问题:Givenanonnegativeintegernumbernum.Foreverynumbersiintherange0≤i≤numcalculatethenumberof1'sintheirbinaryrepresentationandreturnthemasanarray.Example:Fornum=5youshouldreturn[0,1,1,2,1,2].Followup:Iti
Cloudox_
·
2020-02-17 20:34
LeetCode笔记
:539. Minimum Time Difference
问题:Givenalistof24-hourclocktimepointsin"Hour:Minutes"format,findtheminimumminutesdifferencebetweenanytwotimepointsinthelist.Example1:Input:["23:59","00:00"]Output:1Note:Thenumberoftimepointsinthegiven
Cloudox_
·
2020-02-16 02:52
LeetCode笔记
:454. 4Sum II
问题:GivenfourlistsA,B,C,Dofintegervalues,computehowmanytuples(i,j,k,l)therearesuchthatA[i]+B[j]+C[k]+D[l]iszero.Tomakeproblemabiteasier,allA,B,C,DhavesamelengthofNwhere0≤N≤500.Allintegersareintherangeo
Cloudox_
·
2020-02-15 15:50
LeetCode笔记
:242. Valid Anagram
题目:Giventwostringssandt,writeafunctiontodetermineiftisananagramofs.Forexample,s="anagram",t="nagaram",returntrue.s="rat",t="car",returnfalse.Note:Youmayassumethestringcontainsonlylowercasealphabets.Fo
Cloudox_
·
2020-02-15 05:09
LeetCode笔记
:94. Binary Tree Inorder Traversal
问题:Givenabinarytree,returntheinordertraversalofitsnodes'values.Forexample:Givenbinarytree[1,null,2,3],image.pngreturn[1,3,2].Note:Recursivesolutionistrivial,couldyoudoititeratively?大意:给出一个二叉树,返回中序遍历的节
Cloudox_
·
2020-02-13 06:58
LeetCode笔记
:653. Two Sum IV - Input is a BST
问题(Easy):GivenaBinarySearchTreeandatargetnumber,returntrueifthereexisttwoelementsintheBSTsuchthattheirsumisequaltothegiventarget.Example1:Input:Target=9Output:TrueExample2:Input:Target=28Output:False大
Cloudox_
·
2020-02-12 10:57
LeetCode笔记
:566. Reshape the Matrix
问题(Easy):InMATLAB,thereisaveryusefulfunctioncalled'reshape',whichcanreshapeamatrixintoanewonewithdifferentsizebutkeepitsoriginaldata.You'regivenamatrixrepresentedbyatwo-dimensionalarray,andtwopositive
Cloudox_
·
2020-02-12 10:08
LeetCode笔记
:459. Repeated Substring Pattern
问题:Givenanon-emptystringcheckifitcanbeconstructedbytakingasubstringofitandappendingmultiplecopiesofthesubstringtogether.YoumayassumethegivenstringconsistsoflowercaseEnglishlettersonlyanditslengthwilln
Cloudox_
·
2020-02-07 00:26
LeetCode笔记
:696. Count Binary Substrings
问题(Easy):Giveastrings,countthenumberofnon-empty(contiguous)substringsthathavethesamenumberof0'sand1's,andallthe0'sandallthe1'sinthesesubstringsaregroupedconsecutively.Substringsthatoccurmultipletimesa
Cloudox_
·
2020-02-05 01:50
LeetCode笔记
:524. Longest Word in Dictionary through Deleting
问题:Givenastringandastringdictionary,findthelongeststringinthedictionarythatcanbeformedbydeletingsomecharactersofthegivenstring.Iftherearemorethanonepossibleresults,returnthelongestwordwiththesmallestl
Cloudox_
·
2020-01-05 08:24
LeetCode笔记
:515. Find Largest Value in Each Tree Row
问题:Youneedtofindthelargestvalueineachrowofabinarytree.Example:Input:image.pngOutput:[1,3,9]大意:你需要找到二叉树中每一行最大的值。例子:输入:image.png输出:[1,3,9]思路:要找每一行最大的数,我们总归是要遍历二叉树的,遍历二叉树分为BFS和DFS,这里我们要找每行最大的数,那么我们就用BFS,
Cloudox_
·
2020-01-02 03:32
LeetCode笔记
:110. Balanced Binary Tree
问题:Givenabinarytree,determineifitisheight-balanced.Forthisproblem,aheight-balancedbinarytreeisdefinedasabinarytreeinwhichthedepthofthetwosubtreesofeverynodeneverdifferbymorethan1.大意:给出一个二叉树,判断它高度是不是平衡
Cloudox_
·
2020-01-01 21:11
LeetCode笔记
:762. Prime Number of Set Bits in Binary Representation
问题(Easy):GiventwointegersLandR,findthecountofnumbersintherange[L,R](inclusive)havingaprimenumberofsetbitsintheirbinaryrepresentation.(Recallthatthenumberofsetbitsanintegerhasisthenumberof1spresentwhen
Cloudox_
·
2020-01-01 14:35
LeetCode笔记
:6. ZigZag Conversion
问题:Thestring"PAYPALISHIRING"iswritteninazigzagpatternonagivennumberofrowslikethis:(youmaywanttodisplaythispatterninafixedfontforbetterlegibility)PAHNAPLSIIGYIRAndthenreadlinebyline:"PAHNAPLSIIGYIR"Wri
Cloudox_
·
2020-01-01 07:42
LeetCode笔记
:137. Single Number II
问题:Givenanarrayofintegers,everyelementappearsthreetimesexceptforone,whichappearsexactlyonce.Findthatsingleone.Note:Youralgorithmshouldhavealinearruntimecomplexity.Couldyouimplementitwithoutusingextram
Cloudox_
·
2020-01-01 04:19
LeetCode笔记
:104.Maximum Depth of Binary Tree
问题:Givenabinarytree,finditsmaximumdepth.Themaximumdepthisthenumberofnodesalongthelongestpathfromtherootnodedowntothefarthestleafnode.大意:给出一个二叉树,找到其最大的深度。最大深度是指从根节点到最远的叶子节点的最长距离的节点数。思路:要探索二叉树的深度,用递归比较方
Cloudox_
·
2019-12-31 23:23
LeetCode笔记
:394. Decode String
问题:Givenanencodedstring,returnit'sdecodedstring.Theencodingruleis:k[encoded_string],wheretheencoded_stringinsidethesquarebracketsisbeingrepeatedexactlyktimes.Notethatkisguaranteedtobeapositiveinteger.
Cloudox_
·
2019-12-31 22:12
LeetCode笔记
:345. Reverse Vowels of a String
问题:Writeafunctionthattakesastringasinputandreverseonlythevowelsofastring.Example1:Givens="hello",return"holle".Example2:Givens="leetcode",return"leotcede".Note:Thevowelsdoesnotincludetheletter"y".大意:写
Cloudox_
·
2019-12-31 10:08
LeetCode笔记
:8. String to Integer (atoi)
问题:Implementatoitoconvertastringtoaninteger.Hint:Carefullyconsiderallpossibleinputcases.Ifyouwantachallenge,pleasedonotseebelowandaskyourselfwhatarethepossibleinputcases.Notes:Itisintendedforthisprobl
Cloudox_
·
2019-12-31 01:35
LeetCode笔记
:226. Invert Binary Tree
问题:Invertabinarytree.image.pngtoimage.pngTrivia:Google:90%ofourengineersusethesoftwareyouwrote(Homebrew),>butyoucan’tinvertabinarytreeonawhiteboardsofuckoff.大意:反转一个二叉树。从image.png到image.png琐事:Google表示如
Cloudox_
·
2019-12-29 20:20
LeetCode笔记
-0002-两数相加
题目信息给出两个非空的链表用来表示两个非负的整数。其中,它们各自的位数是按照逆序的方式存储的,并且它们的每个节点只能存储一位数字。如果,我们将这两个数相加起来,则会返回一个新的链表来表示它们的和。您可以假设除了数字0之外,这两个数都不会以0开头。示例:输入:(2->4->3)+(5->6->4)输出:7->0->8原因:342+465=807来源:力扣(LeetCode)链接:https://le
dragonMen
·
2019-12-28 07:26
LeetCode笔记
:513. Find Bottom Left Tree Value
问题:Givenabinarytree,findtheleftmostvalueinthelastrowofthetree.Example1:Input:image.pngOutput:1Example2:Input:image.pngOutput:7Note:Youmayassumethetree(i.e.,thegivenrootnode)isnotNULL.大意:给出一个二叉树,找到树最下一
Cloudox_
·
2019-12-27 08:08
LeetCode笔记
:414. Third Maximum Number
问题:Givenanon-emptyarrayofintegers,returnthethirdmaximumnumberinthisarray.Ifitdoesnotexist,returnthemaximumnumber.ThetimecomplexitymustbeinO(n).Example1:Input:[3,2,1]Output:1Explanation:Thethirdmaximum
Cloudox_
·
2019-12-25 05:11
LeetCode笔记
:257. Binary Tree Paths
问题:Givenabinarytree,returnallroot-to-leafpaths.Forexample,giventhefollowingbinarytree:image.pngAllroot-to-leafpathsare:["1->2->5","1->3"]大意:给出一个二叉树,返回所有从根节点到叶子节点的路径。比如给出下面这个二叉树:image.png所有从根节点到叶子节点的路径
Cloudox_
·
2019-12-24 15:39
LeetCode笔记
:303. Range Sum Query - Immutable
问题:Givenanintegerarraynums,findthesumoftheelementsbetweenindicesiandj(i≤j),inclusive.Example:Givennums=[-2,0,3,-5,2,-1]sumRange(0,2)->1sumRange(2,5)->-1sumRange(0,5)->-3Note:Youmayassumethatthearraydo
Cloudox_
·
2019-12-24 05:34
LeetCode笔记
:451. Sort Characters By Frequency
问题:Givenastring,sortitindecreasingorderbasedonthefrequencyofcharacters.Example1:Input:"tree"Output:"eert"Explanation:'e'appearstwicewhile'r'and't'bothappearonce.So'e'mustappearbeforeboth'r'and't'.Ther
Cloudox_
·
2019-12-23 17:11
LeetCode笔记
:349. Intersection of Two Arrays
问题:Giventwoarrays,writeafunctiontocomputetheirintersection.Example:Givennums1=[1,2,2,1],nums2=[2,2],return[2].Note:Eachelementintheresultmustbeunique.Theresultcanbeinanyorder.大意:给出两个数组,写一个函数来计算他们的交叉点。
Cloudox_
·
2019-12-23 09:17
LeetCode笔记
:111. Minimum Depth of Binary Tree
问题:Givenabinarytree,finditsminimumdepth.Theminimumdepthisthenumberofnodesalongtheshortestpathfromtherootnodedowntothenearestleafnode.大意:给出一个二叉树,找到他最小的深度。最小的深度是指从根节点到叶子节点距离最短的节点数。思路:这道题要找到最短的深度,个人认为更应该
Cloudox_
·
2019-12-23 06:40
LeetCode笔记
:477. Total Hamming Distance
问题:TheHammingdistancebetweentwointegersisthenumberofpositionsatwhichthecorrespondingbitsaredifferent.NowyourjobistofindthetotalHammingdistancebetweenallpairsofthegivennumbers.Example:Input:4,14,2Outpu
Cloudox_
·
2019-12-22 05:43
LeetCode笔记
:290. Word Pattern
问题:Givenapatternandastringstr,findifstrfollowsthesamepattern.Herefollowmeansafullmatch,suchthatthereisabijectionbetweenaletterinpatternandanon-emptywordinstr.Examples:pattern="abba",str="dogcatcatdog"
Cloudox_
·
2019-12-20 21:58
LeetCode笔记
:20. Valid Parentheses
问题:Givenastringcontainingjustthecharacters'(',')','{','}','['and']',determineiftheinputstringisvalid.Thebracketsmustcloseinthecorrectorder,"()"and"()[]{}"areallvalidbut"(]"and"([)]"arenot.大意:给出一个只包含'(
Cloudox_
·
2019-12-20 10:34
LeetCode笔记
:122. Best Time to Buy and Sell Stock II
问题:Sayyouhaveanarrayforwhichtheithelementisthepriceofagivenstockondayi.Designanalgorithmtofindthemaximumprofit.Youmaycompleteasmanytransactionsasyoulike(ie,buyoneandselloneshareofthestockmultipletimes
Cloudox_
·
2019-12-16 14:40
LeetCode笔记
:219. Contains Duplicate II
问题:Givenanarrayofintegersandanintegerk,findoutwhethertherearetwodistinctindicesiandjinthearraysuchthatnums[i]=nums[j]andthedifferencebetweeniandjisatmostk.大意:给出一个整型数组和一个整型数k,判断数组中是否任何两个不一样的位置i和j,如果num
Cloudox_
·
2019-12-14 17:30
LeetCode笔记
:112. Path Sum
问题:Givenabinarytreeandasum,determineifthetreehasaroot-to-leafpathsuchthataddingupallthevaluesalongthepathequalsthegivensum.Forexample:Giventhebelowbinarytreeandsum=22,image.pngreturntrue,asthereexista
Cloudox_
·
2019-12-12 09:10
LeetCode笔记
:189. Rotate Array
问题:Rotateanarrayofnelementstotherightbyksteps.Forexample,withn=7andk=3,thearray[1,2,3,4,5,6,7]isrotatedto[5,6,7,1,2,3,4].大意:旋转一个有n个元素的数组,右移k步。比如,n=7,k=3,数组[1,2,3,4,5,6,7]就被旋转为[5,6,7,1,2,3,4]。思路:旋转本身没太
Cloudox_
·
2019-12-07 02:27
LeetCode笔记
:238. Product of Array Except Self
问题:Givenanarrayofnintegerswheren>1,nums,returnanarrayoutputsuchthatoutput[i]isequaltotheproductofalltheelementsofnumsexceptnums[i].SolveitwithoutdivisionandinO(n).Forexample,given[1,2,3,4],return[24,1
Cloudox_
·
2019-12-06 15:05
LeetCode笔记
:438. Find All Anagrams in a String
问题:Givenastringsandanon-emptystringp,findallthestartindicesofp'sanagramsins.StringsconsistsoflowercaseEnglishlettersonlyandthelengthofbothstringssandpwillnotbelargerthan20,100.Theorderofoutputdoesnotm
Cloudox_
·
2019-12-01 08:17
LeetCode笔记
:486. Predict the Winner
问题:Givenanarrayofscoresthatarenon-negativeintegers.Player1picksoneofthenumbersfromeitherendofthearrayfollowedbytheplayer2andthenplayer1andsoon.Eachtimeaplayerpicksanumber,thatnumberwillnotbeavailablef
Cloudox_
·
2019-11-30 21:08
LeetCode笔记
:234. Palindrome Linked List
问题:Givenasinglylinkedlist,determineifitisapalindrome.Followup:CouldyoudoitinO(n)timeandO(1)space?大意:给出一个单链表,判断它是否是回文。进阶:你能在O(n)的时间复杂度和O(1)的空间复杂度下来做吗?思路:回文的意思就是正着读反着读都是一样的。这道题我使用简单的思路,一个个遍历链表节点来倒序组成一个新
Cloudox_
·
2019-11-29 23:31
LeetCode笔记
:205. Isomorphic Strings
问题:Giventwostringssandt,determineiftheyareisomorphic.Twostringsareisomorphicifthecharactersinscanbereplacedtogett.Alloccurrencesofacharactermustbereplacedwithanothercharacterwhilepreservingtheorderofc
Cloudox_
·
2019-11-29 18:14
LeetCode笔记
:38. Count and Say
问题:Thecount-and-saysequenceisthesequenceofintegersbeginningasfollows:1,11,21,1211,111221,...1isreadoffas"one1"or11.11isreadoffas"two1s"or21.21isreadoffas"one2,thenone1"or1211.Givenanintegern,generatet
Cloudox_
·
2019-11-28 01:09
LeetCode笔记
:102. Binary Tree Level Order Traversal
问题:Givenabinarytree,returnthelevelordertraversalofitsnodes'values.(ie,fromlefttoright,levelbylevel).Forexample:Givenbinarytree[3,9,20,null,null,15,7],image.pngreturnitslevelordertraversalas:[[3],[9,20
Cloudox_
·
2019-11-07 11:20
LeetCode笔记
:344. Reverse String
问题:Writeafunctionthattakesastringasinputandreturnsthestringreversed.Example:Givens="hello",return"olleh".大意:写一个函数获取输入的字符串然后返回反转后后的字符串。比如:给出s="hello",返回"olleh"思路:思路很直接就想到,先把字符串拆分成一个个字符组成的数组,新建一个空字符串,然后
Cloudox_
·
2019-11-07 07:33
LeetCode笔记
:326. Power of Three
问题:Givenaninteger,writeafunctiontodetermineifitisapowerofthree.Followup:Couldyoudoitwithoutusinganyloop/recursion?大意:给出一个整数,写一个函数来判断它是否是3的次方数。进阶:你能不能不用循环和递归来做?思路:一开始看这个题目没明白是什么意思,后来查了一下才知道是判断是否3的次方数,所
Cloudox_
·
2019-11-07 07:00
LeetCode笔记
:404. Sum of Left Leaves
问题:Findthesumofallleftleavesinagivenbinarytree.Example:image.pngTherearetwoleftleavesinthebinarytree,withvalues9and15respectively.Return24.大意:计算一个二叉树中所有左叶子节点的和例子:image.png在这个二叉树中有两个左叶子节点,分别为9和15。因此返回2
Cloudox_
·
2019-11-06 03:06
LeetCode笔记
:24. Swap Nodes in Pairs
问题:Givenalinkedlist,swapeverytwoadjacentnodesandreturnitshead.Forexample,Given1->2->3->4,youshouldreturnthelistas2->1->4->3.Youralgorithmshoulduseonlyconstantspace.Youmaynotmodifythevaluesinthelist,on
Cloudox_
·
2019-11-06 03:18
上一页
4
5
6
7
8
9
10
11
下一页
按字母分类:
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
其他